File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
solution/596.Classes More Than 5 Students Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ Complete [solutions](https://github.com/doocs/leetcode/tree/master/solution) to
43
43
| 344 | [ Reverse String] ( https://github.com/doocs/leetcode/tree/master/solution/344.Reverse%20String ) | ` Two Pointers ` , ` String ` |
44
44
| 581 | [ Shortest Unsorted Continuous Subarray] ( https://github.com/doocs/leetcode/tree/master/solution/581.Shortest%20Unsorted%20Continuous%20Subarray ) | ` Array ` |
45
45
| 595 | [ Big Countries] ( https://github.com/doocs/leetcode/tree/master/solution/595.Big%20Countries ) | ` SQL ` |
46
+ | 596 | [ Classes More Than 5 Students] ( https://github.com/doocs/leetcode/tree/master/solution/596.Classes%20More%20Than%205%20Students ) | ` SQL ` |
46
47
| 605 | [ Can Place Flowers] ( https://github.com/doocs/leetcode/tree/master/solution/605.Can%20Place%20Flowers ) | ` Array ` |
47
48
| 695 | [ Max Area of Island] ( https://github.com/doocs/leetcode/tree/master/solution/695.Max%20Area%20of%20Island ) | ` Array ` , ` Depth-first Search ` |
48
49
| 703 | [ Kth Largest Element in a Stream] ( https://github.com/doocs/leetcode/tree/master/solution/703.Kth%20Largest%20Element%20in%20a%20Stream ) | ` Heap ` |
Original file line number Diff line number Diff line change
1
+ ## 超过5名学生的课
2
+ ### 题目描述
3
+
4
+ 有一个 ` courses ` 表 ,有: ** student(学生)** 和 ** class(课程)** 。
5
+
6
+ 请列出所有超过或等于5名学生的课。
7
+
8
+ 例如,表:
9
+ ```
10
+ +---------+------------+
11
+ | student | class |
12
+ +---------+------------+
13
+ | A | Math |
14
+ | B | English |
15
+ | C | Math |
16
+ | D | Biology |
17
+ | E | Math |
18
+ | F | Computer |
19
+ | G | Math |
20
+ | H | Math |
21
+ | I | Math |
22
+ +---------+------------+
23
+ ```
24
+
25
+ 应该输出:
26
+ ```
27
+ +---------+
28
+ | class |
29
+ +---------+
30
+ | Math |
31
+ +---------+
32
+ ```
33
+
34
+ ** Note:**
35
+ 学生在每个课中不应被重复计算。
36
+
37
+ ### 解法
38
+ 注意学生可能被重复计算,需要 ` distinct ` 。
39
+
40
+ ``` sql
41
+ # Write your MySQL query statement below
42
+ select class from courses group by class having count (distinct student) >= 5
43
+
44
+ ```
You can’t perform that action at this time.
0 commit comments