Uber-style Company ChallengeBeginnerVerified answerSQLite live

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_idINTEGER
  • first_nameVARCHAR(50)
  • last_nameVARCHAR(50)
  • ratingREAL
  • total_tripsINTEGER
  • city_idINTEGER

cities

  • city_idINTEGER
  • city_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_id

Why 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_nameratingtotal_tripscity_name
Jane Smith4.9980San Francisco
John Doe4.81250San Francisco
Mike Johnson4.71100New York
Sarah Williams4.6850New York
David Brown4.5720Los Angeles

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Interview Practice

Return to the complete interview preparation experience.