Exercise: Count with HAVING
Courses with more than 5 students.
Solution
sql
1SELECT c.course_name, COUNT(*) AS count
2FROM students s
3JOIN courses c ON s.course_id = c.id
4GROUP BY c.course_name
5HAVING COUNT(*) > 5;
Courses with more than 5 students.
1SELECT c.course_name, COUNT(*) AS count
2FROM students s
3JOIN courses c ON s.course_id = c.id
4GROUP BY c.course_name
5HAVING COUNT(*) > 5;