首页 > 其他 > 详细

8 group by 约束条件

时间:2020-02-15 23:09:19      阅读:72      评论:0      收藏:0      [点我收藏+]
select post from employee group by post; # 只能取分组的字段

#聚合函数 
max
min
avg
sum
count

#每个职位有多少个员工
select post,count(id) from employee group by post;
select post,count(id) as emp_count from employee group by post;

select post,max(salary) as emp_count from employee group by post;
select post,min(salary) as emp_count from employee group by post;
select post,avg(salary) as emp_count from employee group by post;
select post,sum(age) as emp_count from employee group by post;

select post,group_concat(id,name) from employee group by post;

 

8 group by 约束条件

原文:https://www.cnblogs.com/zhujing666/p/12313774.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!