sql >> Base de Datos >  >> RDS >> Mysql

Mysql Count(*) as Total DONDE Total?

Creo que querías filtrar grupos. Utilice HAVING COUNT(*) en lugar de WHERE :

SELECT Id, QId, UName, Ans, Date, Count(*) * 10 as Total
FROM question
GROUP BY UName
HAVING Count(*)

Si desea ordenar grupos por número de elementos, utilice ORDER BY :

SELECT Id, QId, UName, Ans, Date, Count(*) * 10 as Total
FROM question
GROUP BY UName
ORDER BY Count(*) DESC