SELECT
Id, QId, UName, Ans, Date, COUNT(*) * 10 as Total
FROM
question
WHERE
COUNT(*)
DESC
GROUP BY
UName
不工作:(Mysql Count(*)as Total WHERE Total?
SELECT
Id, QId, UName, Ans, Date, COUNT(*) * 10 as Total
FROM
question
WHERE
COUNT(*)
DESC
GROUP BY
UName
不工作:(Mysql Count(*)as Total WHERE Total?
我想你想過濾組使用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
WHERE過濾器行,HAVING過濾器組 – 2010-02-11 17:00:29
@KM:感謝您的評論 – 2010-02-11 17:05:56
where'COUNT(*)DESC' what? – Quassnoi 2010-02-11 16:59:34
這個我沒有添加:S – s3yfullah 2010-02-11 22:14:21