题目标签:
题目给了我们 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 Solution
LeetCode 题目列表 - LeetCode Questions List
题目来源:https://leetcode.com/
原文地址:https://www.cnblogs.com/jimmycheng/p/11450689.html
时间: 2024-09-28 20:57:44