select column,group_function
from table
[ where condation ]
[ group by expression]
[ having group_condation ]
[ order by column]
where子句中不能应用group by语句,所以用having对group by出来的分组数据做限制。