CJCoding With Joseph
15free / daySign inCreate account

Courses Beating the College Average

In a CTE named course_avg, compute each course's average grade (course_id and avg_grade, rounded to 2 places) over the enrollments that have a grade. Join it to courses and return code, title and avg_grade for the courses whose average is above the average of every graded enrollment taken together: one AVG(grade) over the whole enrollments table (a scalar subquery or a second CTE), not an average of the course averages. Sort by avg_grade descending.

Expected result:

+---------+-----------------------------+-----------+
| code    | title                       | avg_grade |
+---------+-----------------------------+-----------+
| MATH220 | Linear Algebra              |        95 |
| ENG101  | Academic Writing            |      81.6 |
| CS310   | Operating Systems           |        79 |
| CS101   | Introduction to Programming |     77.56 |
+---------+-----------------------------+-----------+
4 rows
Hints3 available
Topics:
CTEs
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sel, ins, desc)

Results

Run your SQL to see every statement's output here, then how it compares with the expected answer.

Not sure what is in a table? SHOW TABLES lists them and DESCRIBE students shows the columns — or open the database browser on the left.