SELECT
Id, QId, UName, Ans, Date, COUNT(*) * 10 as Total
FROM
question
WHERE
COUNT(*)
DESC
GROUP BY
UName
不起作用:(
答案 0 :(得分:5)
我想你想要过滤群组。使用HAVING COUNT(*)
代替WHERE
:
SELECT Id, QId, UName, Ans, Date, Count(*) * 10 as Total
FROM question
GROUP BY UName
HAVING Count(*)
如果按组件数对组进行排序,请使用ORDER BY
:
SELECT Id, QId, UName, Ans, Date, Count(*) * 10 as Total
FROM question
GROUP BY UName
ORDER BY Count(*) DESC