High-Rated Drivers
Which drivers have a rating of 4.5 or above, and how many trips have they completed?
- Joins
- Filtering
- Sorting
Challenge brief
Understand the request
Quality Assurance wants to feature top-rated drivers in the app to reward performance and attract new riders.
List all drivers with rating >= 4.5 showing name, rating, total trips, and city.
Return
- driver_name (first + last)
- rating
- total_trips
- city_name
Constraints
- Return drivers rated 4.5 or higher
- Order by rating descending, then driver ID
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
drivers
driver_idINTEGERfirst_nameVARCHAR(50)last_nameVARCHAR(50)ratingREALtotal_tripsINTEGERcity_idINTEGER
cities
city_idINTEGERcity_nameVARCHAR(100)
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
Driver ratings and trip totals are in drivers. City names are in cities. JOIN on city_id. Filter by rating.
Hint 2
INNER JOIN drivers to cities on city_id. WHERE d.rating >= 4.5. ORDER BY d.rating DESC.
Hint 3
Connect each driver to a city, filter on the rating threshold, and add the identifier as the final ordering key.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT d.first_name || ' ' || d.last_name AS driver_name, d.rating, d.total_trips, c.city_name FROM drivers d INNER JOIN cities c ON d.city_id = c.city_id WHERE d.rating >= 4.5 ORDER BY d.rating DESC, d.driver_idWhy this works
All 5 drivers in the dataset have ratings between 4.5 and 4.9 — all qualify. total_trips is a denormalised counter column in drivers, so no aggregation needed.
Success check
5 drivers — all drivers meet the 4.5 threshold; Jane Smith leads at 4.9
Expected result
Use this output to verify values, aliases, ordering, and row count.
| driver_name | rating | total_trips | city_name |
|---|---|---|---|
| Jane Smith | 4.9 | 980 | San Francisco |
| John Doe | 4.8 | 1250 | San Francisco |
| Mike Johnson | 4.7 | 1100 | New York |
| Sarah Williams | 4.6 | 850 | New York |
| David Brown | 4.5 | 720 | Los Angeles |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Explore related company challenges
Airbnb
Independent Airbnb-style marketplace, booking, listing, payment, review, and guest analytics SQL practice.
Amazon
Independent Amazon-style e-commerce, warehouse, inventory, and customer analytics SQL practice.
Google
Independent Google-style search, advertising, user-engagement, and video-product SQL practice.
Return to the complete interview preparation experience.