用group by
如有个student表里有性别sex来统计
select sex,count(*) from student group by sex;
转载于:https://www.cnblogs.com/chimmu/p/6212317.html