码迷,mamicode.com
首页 > 其他好文 > 详细

8 group by 约束条件

时间:2020-02-15 21:45:07      阅读:61      评论:0      收藏:0      [点我收藏+]

标签:color   max   nbsp   聚合   post   span   min   sele   select   

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 约束条件

标签:color   max   nbsp   聚合   post   span   min   sele   select   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!