File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 111070 . 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 |
Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments