Skip
Arish's avatar

195. Practice - JOIN GROUP 5


Exercise: Multiple Aggregates

Get count, average, and max marks per course.

Solution

sql
1SELECT c.course_name,
2  COUNT(*) AS students,
3  AVG(s.marks) AS avg,
4  MAX(s.marks) AS max
5FROM students s
6JOIN courses c ON s.course_id = c.id
7GROUP BY c.course_name;