✔️ GROUP BY | HAVING | COUNT
IntuitionTo find all the classes that have at least five students, we need to count the number of students in each class. If the count is 5 or more, we include
# Intuition
To find all the classes that have at least five students, we need to count the number of students in each class. If the count is 5 or more, we include that class in our output.

# Approach
1. **Group by class** - Since multiple students can belong to the same class, we use the GROUP BY clause to count students for each class.
2. **Count students** - We use the COUNT(student) function to get the number of students per class.
3. **Filter classes with at least 5 students** - We apply the HAVING clause to keep only those classes where the count is 5 or more.
4. **Select only the class name** - The final result should return only the class names that meet the condition.

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

---

![upvote.png](https://assets.leetcode.com/users/images/ff24b1bf-3cdd-476b-9e8a-9441c58d5b85_1740834686.0852482.png)


['MySQL', 'Oracle', 'MS SQL Server', 'PostgreSQL']