1 group by

可用于单个字段分组,也可用于多个字段分组
select name, gender from people group by name, gender;
image.png

2 group_concat(字段名)

统计每个分组指定字段的信息集合,每个信息之间使用逗号进行分割
select gender,group_concat(name) from people group by gender;
image.png

3 group by + 聚合函数的使用

select gender,avg(age) from people group by gender;
image.png

4 group by + having的使用

select gender, count(*) from people group by gender having count(*)>2;
image.png