1 group by
可用于单个字段分组,也可用于多个字段分组select name, gender from people group by name, gender;
2 group_concat(字段名)
统计每个分组指定字段的信息集合,每个信息之间使用逗号进行分割select gender,group_concat(name) from people group by gender;
3 group by + 聚合函数的使用
select gender,avg(age) from people group by gender;
4 group by + having的使用
select gender, count(*) from people group by gender having count(*)>2;