Skip
Arish's avatar

196. Complex Grouping Across Tables


Multiple Table Grouping

sql
1SELECT d.dept_name, c.course_name, COUNT(*) AS students
2FROM departments d
3JOIN courses c ON d.id = c.dept_id
4JOIN students s ON c.id = s.course_id
5GROUP BY d.dept_name, c.course_name;