问题描述
其实我的系统在上面显示的评论数量最多,包括喜欢和不喜欢的内容。
这意味着100like / 100dislikes的评论是我认为这是可以理解的:)
这是如何排名upvote / downvote,加/减,喜欢/不喜欢等经典问题。有几种可能的解决方案,但它们可能会在特定条件下给出错误结果。
我强烈建议阅读和使用
示例代码(您可以根据需要轻松调整它):
SELECT id,((positive + 1.9208)/(positive + negative) -
1.96 * SQRT((positive + negative)/(positive + negative)+ 0.9604)/
(正数+负数))/(1 + 3.8416 /(正数+负数))
AS ci_lower_bound
FROM your_tab
WHERE正数+负数> 0
ORDER BY ci_lower_bound DESC;
I have table of comments which includes likes and dislikes, now i have problem with proper order..
Actually my system shows comments with greatest amount of likes on top.
I'm looking for something like system in youtube.
It means that comment with 100like/100dislikes is higher in order than 1/1..
I hope this is understandable :)
This is classic problem how to rank upvote/downvote, plus/minus, like/dislike and so on. There are a few possible solutions but they may give wrong result in specific conditions.
I strongly recommend reading and using ordering like in How Not To Sort By Average Rating
Sample code (you can easily adapt it for your needs):
SELECT id, ((positive + 1.9208) / (positive + negative) -
1.96 * SQRT((positive * negative) / (positive + negative) + 0.9604) /
(positive + negative)) / (1 + 3.8416 / (positive + negative))
AS ci_lower_bound
FROM your_tab
WHERE positive + negative > 0
ORDER BY ci_lower_bound DESC;
这篇关于MYSQL按喜欢/不喜欢和受欢迎程度排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!