Exercise: Sort Groups
Sort grades by average marks descending.
Solution
sql
1SELECT grade, AVG(marks) AS avg_marks
2FROM students
3GROUP BY grade
4ORDER BY avg_marks DESC;
Sort grades by average marks descending.
1SELECT grade, AVG(marks) AS avg_marks
2FROM students
3GROUP BY grade
4ORDER BY avg_marks DESC;