我有一个看起来像这样的数据库:
id|text|rating|TimeOfRating
对于描述:如果用户以 5 分中的 4 分对评论进行评分,则评分增加 4 分,TimeOfRating 增加 1 分。
使用 php 如何过滤掉 10 条评价最高的评论?
干杯!
这将为您提供平均评分:
SELECT
id,
text,
(rating/TimeOfRating) AS score
FROM tablename
ORDER BY score DESC
LIMIT 10
根据您提供的信息,这可以满足您的要求。
SELECT id, text, rating, TimeOfRating
FROM
(SELECT id, text
CASE
WHEN rating = 4 THEN rating + 5
ELSE rating
END AS rating,
CASE
WHEN rating = 4 THEN TimeOfRating + 1
ELSE TimeOfRating
END AS TimeOfRating
FROM pickles) a
ORDER BY rating DESC
LIMIT 10
什么类型的柱子TimeOfRating
?