我有一个问题。我试图在我的 SQL 查询中使用 IF 语句,他们在进一步的计算中使用该语句的结果:
SELECT average_rating, number_of_ratings,
IF(number_of_ratings < 500 AND number_of_ratings > 100, 0.90,
IF(number_of_ratings>=500 AND number_of_ratings<=1000, 0.95,
IF(number_of_ratings>1000, 0.99, 0.80)
)
) AS rating_factor,
ROUND((rating_factor * average_rating), 4) AS factored_rating
FROM table
ORDER by factored_rating DESC
但是,它不起作用并返回错误:“字段列表”中的未知列“rating_factor”
有人知道如何使它工作吗?
提前致谢。