All problems

Who Tops the Dean's List?

easySQLSorting

Fairhaven University's dean is finalising this term's honours list and wants the single best grade point average on record checked by hand, together with the name of the student it belongs to.

The name and the figure have to arrive together, which is the awkward part. Reading the largest number out of a column is easy; making the database also hand back the rest of that student's row takes a different move, because a maximum on its own is just a number and has forgotten which row produced it.

students — one row per enrolled student. gpa is their grade point average out of 4.0.

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 returning a single row with two columns, name and gpa, for the student with the highest grade point average. Exactly one row comes back.

Example output — shape only, on an invented student and average.

name gpa
Tara Villalobos 3.72

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…