Exercise: Count per Course
Count students per course.
Solution
sql
1SELECT c.course_name, COUNT(s.id) AS count
2FROM courses c
3LEFT JOIN students s ON s.course_id = c.id
4GROUP BY c.course_name;
Count students per course.
1SELECT c.course_name, COUNT(s.id) AS count
2FROM courses c
3LEFT JOIN students s ON s.course_id = c.id
4GROUP BY c.course_name;