LeetCode 596. Classes More Than 5 Students (超过5名学生的课)
题目标签:
题目给了我们 courses 表格,让我们找到 一个有至少5名学生的班级。
利用group by 把班级分类,在用Having count 来判断是否有5名,注意这里还需要用 distinct 来判断是否有重复的学生在同一个班级里。
Java Solution:
Runtime: 205 ms, faster than 51.77%
Memory Usage: N/A
完成日期:07/02/2019
关键点:GROUP BY && HAVING count
# Write your MySQL query statement below SELECT class FROM courses GROUP BY class HAVING count(distinct student) >= 5;
LeetCode 题目列表 - LeetCode Questions List
题目来源:https://leetcode.com/