select 列1,列2,聚合... from 表名 group by 列1,列2,列3...
select gender as 性别,count(*) from students group by gender;
select hometown as 家乡,count(*) from students group by hometown;
select 列1,列2,聚合... from 表名 group by 列1,列2,列3... having 列1,...聚合...
方案一 select count(*) from students where gender=1; ----------------------------------- 方案二: select gender as 性别,count(*) from students group by gender having gender=1;
原文:https://www.cnblogs.com/wuzaipei/p/9819620.html