You are given a table Courses that contains information about student enrollments in various classes.
Table: Courses
| Column Name | Type |
|---|---|
| student | varchar |
| class | varchar |
The combination of (student, class) is the primary key for this table. Each row indicates the name of a student and the class in which they are enrolled.
Task: Write a SQL solution to find all the classes that have at least five students. Return the result table in any order.
Table Schema
| Column Name | Type | Description |
|---|---|---|
student
PK
|
varchar | Name of the student |
class
PK
|
varchar | Name of the class the student is enrolled in |
Input & Output
| student | class |
|---|---|
| A | Math |
| B | English |
| C | Math |
| D | Biology |
| E | Math |
| F | Computer |
| G | Math |
| H | Math |
| I | Math |
| class |
|---|
| Math |
Math has 6 students (A, C, E, G, H, I) which is ≥ 5, so it's included. English has 1 student, Biology has 1 student, and Computer has 1 student, all less than 5.
| student | class |
|---|---|
| Alice | Math |
| Bob | Math |
| Charlie | Math |
| David | Math |
| Eve | Math |
| Frank | English |
| Grace | English |
| Henry | English |
| Iris | English |
| Jack | English |
| class |
|---|
| English |
| Math |
Both Math and English have exactly 5 students each, so both classes are returned in the result.
| student | class |
|---|---|
| Student1 | Physics |
| Student2 | Chemistry |
| Student3 | Physics |
| Student4 | Biology |
| class |
|---|
Physics has 2 students, Chemistry has 1 student, and Biology has 1 student. No class has at least 5 students, so the result is empty.
Constraints
-
1 ≤ number of students ≤ 1000 -
1 ≤ number of classes ≤ 1000 -
studentandclassare non-empty strings