
select class from Courses group by class
having count(student)>=5;
group by 之后 可以使用聚合函数
where 优先级高于 group by 无法使用聚合函数
having 优先级低于 group by 可以使用聚合函数
本文介绍了SQL查询中的groupby关键字及其与having子句的用法区别:where用于基础条件过滤,其后不能跟聚合函数;而having用于在分组后进行条件筛选,可以使用聚合函数,如检查学生数量大于等于5的课程。

select class from Courses group by class
having count(student)>=5;
group by 之后 可以使用聚合函数
where 优先级高于 group by 无法使用聚合函数
having 优先级低于 group by 可以使用聚合函数

被折叠的 条评论
为什么被折叠?