Classes More Than 5 Students
Problem
Table: Courses
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| student | varchar |
| class | varchar |
+-------------+---------+
(student, class) is the primary key (combination of columns with unique values) for this table.
Each row of this table indicates the name of a student and the class in which they are enrolled.
Write a solution to find all the classes that have at least five students.
Return the result table in any order.
Solution
The problem Classes More Than 5 Students
can be solved using the keyword GROUP BY
along with the function COUNT
.
Implementation
# Write your MySQL query statement below
SELECT class
FROM courses
GROUP BY class
HAVING COUNT(student) >= 5;