Classes More Than 5 Students

You can write a MySQL query that groups the classes by name and filters those having at least five students. Here’s the query:

1
2
3
4
SELECT class
FROM Courses
GROUP BY class
HAVING COUNT(student) > 4;

Explanation:

  • The GROUP BY clause groups the rows by the class.
  • The HAVING clause filters the classes by the condition that the count of students in the class must be at least five.