Solving by GROUP and COUNT : using HAVING instead of WHERE
IntuitionSince Courses.student has unique values, I can GROUP by Courses.class.
then a simple WHERE COUNT(Courses.student) >= 5 should be enough.SELECT c.class
# Intuition

Since Courses.student has unique values, I can GROUP by Courses.class.
then a simple WHERE COUNT(Courses.student) >= 5 should be enough.

SELECT c.class
FROM Courses c
GROUP BY c.class
WHERE COUNT(c.student) >= 5;

# Approach

SELECT c.class
FROM Courses c
GROUP BY c.class
HAVING COUNT(c.student) >= 5; // HAVING instead of WHERE because of the aggregating effect of the GROUP statement.

# Conclusion

Source: https://www.w3schools.com/mysql/mysql_having.asp

The MySQL HAVING Clause:
The HAVING clause was added to SQL because the WHERE keyword cannot be used with aggregate functions.

Difference Between WHERE and HAVING
Clause	Works on Individual Rows?	Works on Aggregated Data?	Used with GROUP BY?
WHERE	✅ Yes	❌ No	❌ No
HAVING	❌ No	✅ Yes	✅ Yes


# Code
```mysql []
SELECT c.class
FROM Courses c
GROUP BY c.class
HAVING COUNT(c.student) >= 5;

```
['MySQL']