其他分享
首页 > 其他分享> > 596. 超过5名学生的课 + group by + having

596. 超过5名学生的课 + group by + having

作者:互联网

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;

标签:group,596,having,MySQL,class,select
来源: https://www.cnblogs.com/GarrettWale/p/14507890.html