Mysql group_concat()
1. 表格内容
2. 分组查询,查出各部门人数,以及各部门员工姓名
select edept,count(*),group_concat(ename) from emp_info a group by edept;
3. 分组查询,查出各部门人数,以及各部门员工姓名,salary,kpi
查询1:
select edept,count(*),group_concat(ename,salary,kpi) from emp_info a group by edept;
结果1:
查询2:
select edept,count(*),group_concat(ename," ",salary," ",kpi) from emp_info a group by edept;
结果2:
示例3:
select edept , group_concat(ename) from emp_info group by edept having avg(salary)>5000;
结果3:
查询4:
select group_concat(ename) from emp_info;
结果4:
查询5:
select group_concat(ename) from emp_info where salary > 4000;
结果5:
钟声敲响了日落,柏油路跃过山坡,一直通向北方的是我们想象,长大后也未曾经过~