File tree Expand file tree Collapse file tree 1 file changed +0
-33
lines changed Expand file tree Collapse file tree 1 file changed +0
-33
lines changed Original file line number Diff line number Diff line change 1- -- 596. Classes More Than 5 Students
2- -- SQL Schema
3- -- There is a table courses with columns: student and class
4- --
5- -- Please list out all classes which have more than or equal to 5 students.
6- --
7- -- For example, the table:
8- --
9- -- +---------+------------+
10- -- | student | class |
11- -- +---------+------------+
12- -- | A | Math |
13- -- | B | English |
14- -- | C | Math |
15- -- | D | Biology |
16- -- | E | Math |
17- -- | F | Computer |
18- -- | G | Math |
19- -- | H | Math |
20- -- | I | Math |
21- -- +---------+------------+
22- -- Should output:
23- --
24- -- +---------+
25- -- | class |
26- -- +---------+
27- -- | Math |
28- -- +---------+
29- --
30- --
31- -- Note:
32- -- The students should not be counted duplicate in each course.
33-
341select class from courses
352group by class
363having count (distinct student) >= 5 ;
You can’t perform that action at this time.
0 commit comments