Departmental Bragging Rights
Every year at the Fairhaven University open day, each department claims its students are the sharpest in the building, and every year nobody can settle it. The provost has decided to end the argument with a number: the mean grade point average of the students reading each subject.
The majors are not listed anywhere on their own — they exist only as text written on each student's row — so the subjects in the report are whatever the students are actually reading.
students — one row per enrolled student. gpa is the grade point average already on file for that student, on a 0-4 scale.
| id | name | major | gpa |
|---|---|---|---|
| 1 | Nora Fischer | Computer Science | 3.8 |
| 2 | Omar Haddad | Statistics | 3.4 |
| 3 | Petra Novakova | Computer Science | 3.9 |
| 4 | Quinn Walsh | Mathematics | 3.1 |
| 5 | Ravi Shah | Statistics | 3.6 |
The table already exists in the database — there is nothing to create or load.
Task: Write a query that returns one row per major, with major and the mean grade point average of its students rounded to two decimal places as avg_gpa, strongest major first.
Example output
Shape only — these majors and averages are invented:
| major | avg_gpa |
|---|---|
| Physics | 3.72 |
| Economics | 3.28 |
| Chemistry | 2.9 |
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in