Skip to content

Commit b704d10

Browse files
refactor 596
1 parent b7d55b7 commit b704d10

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

database/_596.sql

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
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+
134
select class from courses
235
group by class
336
having count(distinct student) >= 5;

0 commit comments

Comments
 (0)