students |
|
||||||||||||||||||||||||
1、group by 和 having 函数的应用
select max(msg_timestamp) as '最大秒数',count(distinct user_id) as '企微购房通用户数' from bb_wework_group_user_info where updated_at like '2022-01-19%' group by msg_timestamp having max(msg_timestamp) ;
#例子: #1、查找每个班中及格的学生的人数 select class,count(*) from students group by class having grade>=60; 2、查找每个班中总成绩最优秀的学生 select stu.class,max(stu.grade) from (select stu,class,math_grade+chinese_grade as grade from students group by students)stu group by stu.class having max (stu.grade);
2、distinct函数用途:去除表或列中的重复项。
#查出不重复的老师的数据
select distinct teacher_id from students ;
标签:group,grade,学习,stu,students,sql,整理,class,select From: https://www.cnblogs.com/xuchuanhui/p/18052204