Your question is Top Drivers by Monthly Rating. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Uber wants a monthly leaderboard of driver quality. Write a PostgreSQL query that returns the top 10 drivers by average rating for the last month, using a fixed reporting date of 2026-06-01.
ride_status = 'completed'.rating is NULL.driver_name, avg_rating rounded to 2 decimals, and completed_rides.avg_rating descending, then completed_rides descending, then driver_name ascending.drivers| column | type | description |
|---|---|---|
| driver_id | INT | Unique driver identifier |
| driver_name | VARCHAR(100) | Driver display name |
rides| column | type | description |
|---|---|---|
| ride_id | INT | Unique ride identifier |
| driver_id | INT | Driver assigned to the ride |
| ride_date | DATE | Date of the ride |
| rating | DECIMAL(3,2) | Passenger rating for the ride |
| ride_status | VARCHAR(20) | Ride status such as completed or canceled |
| Column | Type | Description |
|---|---|---|
| driver_idPK | INT | Unique driver identifier |
| driver_name | VARCHAR(100) | Driver display name |
| Column | Type | Description |
|---|---|---|
| ride_idPK | INT | Unique ride identifier |
| driver_id | INT | Driver assigned to the ride |
| ride_date | DATE | Date of the ride |
| rating | DECIMAL(3,2) | Passenger rating for the ride |
| ride_status | VARCHAR(20) | Ride status such as completed or canceled |