Uber Operations needs to identify drivers who completed at least 50 trips during the previous calendar month but had a lower completion rate during the most recent seven-day period. Assume the reporting snapshot date is 2025-03-31.
Write a PostgreSQL query that joins driver details with daily trip metrics.
A completion rate is completed trips divided by requested trips. Treat a NULL completed-trip value as zero and avoid division by zero.
| Column | Type | Description |
|---|---|---|
| driver_idPK | INT | Unique driver identifier |
| driver_name | VARCHAR(100) | Driver's full name |
| city | VARCHAR(50) | Uber operating city |
| status | VARCHAR(20) | Current driver status |
| Column | Type | Description |
|---|---|---|
| metric_idPK | INT | Unique daily metric identifier |
| driver_id | INT | References drivers.driver_id |
| metric_date | DATE | Date covered by the metric |
| requested_trips | INT | Trips requested from the driver |
| completed_trips | INT | Trips completed by the driver |