Exercise: Average by Course
Find average marks per course.
Solution
sql
1SELECT c.course_name, AVG(s.marks) AS avg_marks
2FROM students s
3JOIN courses c ON s.course_id = c.id
4GROUP BY c.course_name;
Find average marks per course.
1SELECT c.course_name, AVG(s.marks) AS avg_marks
2FROM students s
3JOIN courses c ON s.course_id = c.id
4GROUP BY c.course_name;