Beating the Average
The scholarship committee at Fairhaven University screens on relative standing rather than a fixed number. A cut-off of 3.5 would mean something different in a strong year than in a weak one, so the rule the committee settled on is: you are through to the next round if your grade point average beats the average of the student body you are actually in.
Nobody knows what that average is until the query works it out, and it changes every time a student joins or leaves — which is the point. Sitting exactly on the average is not beating it.
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 name and gpa for every student whose grade point average is strictly above the mean grade point average of all students, strongest first.
Example output
Shape only — these students and averages are invented:
| name | gpa |
|---|---|
| Mira Sun | 3.95 |
| Dana Ruiz | 3.7 |
| Yara Blum | 3.45 |
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