Skip to content

Commit 6527da5

Browse files
596. Classes More Than 5 Students
Co-Authored-By: Antim-IWP <[email protected]>
1 parent 1a6981f commit 6527da5

2 files changed

Lines changed: 56 additions & 6 deletions

File tree

1070. Product Sales Analysis III.sql

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
1070. Product Sales Analysis III
2-
Medium
3-
Topics
4-
Companies
5-
SQL Schema
6-
Pandas Schema
7-
Table: Sales
2+
83

94
+-------------+-------+
105
| Column Name | Type |
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
596. Classes More Than 5 Students
2+
3+
+-------------+---------+
4+
| Column Name | Type |
5+
+-------------+---------+
6+
| student | varchar |
7+
| class | varchar |
8+
+-------------+---------+
9+
(student, class) is the primary key (combination of columns with unique values) for this table.
10+
Each row of this table indicates the name of a student and the class in which they are enrolled.
11+
12+
13+
Write a solution to find all the classes that have at least five students.
14+
15+
Return the result table in any order.
16+
17+
The result format is in the following example.
18+
19+
20+
21+
Example 1:
22+
23+
Input:
24+
Courses table:
25+
+---------+----------+
26+
| student | class |
27+
+---------+----------+
28+
| A | Math |
29+
| B | English |
30+
| C | Math |
31+
| D | Biology |
32+
| E | Math |
33+
| F | Computer |
34+
| G | Math |
35+
| H | Math |
36+
| I | Math |
37+
+---------+----------+
38+
Output:
39+
+---------+
40+
| class |
41+
+---------+
42+
| Math |
43+
+---------+
44+
Explanation:
45+
- Math has 6 students, so we include it.
46+
- English has 1 student, so we do not include it.
47+
- Biology has 1 student, so we do not include it.
48+
- Computer has 1 student, so we do not include it.
49+
50+
51+
# Write your MySQL query statement below
52+
SELECT class
53+
FROM Courses
54+
GROUP BY class
55+
HAVING COUNT(student) >= 5;

0 commit comments

Comments
 (0)