596. 超过5名学生的课
LeetCode_MySql_596
题目描述
方法一:使用group by + where + 子查询
# Write your MySQL query statement below
select c1.class
from (
select class, count(distinct student) as num
from courses
group by class
) as c1
where 5 <= c1.num;
方法二:使用group by + having
# Write your MySQL query statement below
select class
from courses
group by class
having count(distinct student) >= 5;