题目来源:
leetcode题目,网址:596. 超过5名学生的课 - 力扣(LeetCode)
解题思路:
先对classes进行分组聚合,然后筛选出组内数据数量大于4的课程。
解题代码:
# Write your MySQL query statement below
select class
from Courses
group by class
having count(student)>4
总结:
官方题解使用 distinct 修饰了student,感觉没必要。