SELECT
Id, QId, UName, Ans, Date, COUNT(*) * 10 as Total
FROM
question
WHERE
COUNT(*)
DESC
GROUP BY
UName
doesn't work :(
SELECT
Id, QId, UName, Ans, Date, COUNT(*) * 10 as Total
FROM
question
WHERE
COUNT(*)
DESC
GROUP BY
UName
doesn't work :(
I think you wanted to filter groups. Use HAVING COUNT(*)
instead of WHERE
:
SELECT Id, QId, UName, Ans, Date, Count(*) * 10 as Total
FROM question
GROUP BY UName
HAVING Count(*)
If you what to sort groups by number of elements then use ORDER BY
:
SELECT Id, QId, UName, Ans, Date, Count(*) * 10 as Total
FROM question
GROUP BY UName
ORDER BY Count(*) DESC