All problems

The Five-Star Candidates

easySQLFilteringSorting

UrbanHop is launching a Pro badge that shows next to a driver's name in the app, and the bar the trust team set is a running rating of 4.8 or better — 4.8 exactly qualifies, since the rating is only ever displayed to one decimal place and drawing the line between 4.80 and 4.81 would be indefensible.

The list goes to a designer who has to mock up the badge next to real names, so it needs the rating beside each name, best first, with an order that does not shuffle between two runs.

drivers — one row per driver on the platform. rating is their running star rating out of 5, and city is the city they drive in.

id name city rating
1 Sam Rios Austin 4.9
2 Priya Desai Denver 4.6
3 Oscar Lund Seattle 4.8
4 Nina Cole Austin 4.2

The table already exists in the database — there is nothing to create or load.

Task: Write a query that returns name and rating for every driver whose rating is 4.8 or better, the bar itself included. Highest rating first; drivers sharing a rating are separated alphabetically by name.

Example output

Shape only — these drivers and ratings are invented:

name rating
Dana Fox 4.95
Milo Reyes 4.85

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…