views:

260

answers:

1
SELECT
  Id, QId, UName, Ans, Date, COUNT(*) * 10 as Total
FROM
  question
WHERE
  COUNT(*)
DESC
GROUP BY
  UName

doesn't work :(

+3  A: 

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
Ivan Nevostruev
WHERE filters on rows, HAVING filters groups
KM
@KM: Thanks for your comment
Ivan Nevostruev