Your question is Average Delivery Time by Driver (SQL). 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.
Porter Operations needs to monitor how long active drivers take to complete deliveries. Write a PostgreSQL query that calculates each active driver's average completed delivery time.
completed and both pickup and delivery timestamps present.NULL when a driver has no eligible deliveries.| Column | Type | Description |
|---|---|---|
| driver_idPK | INTEGER | Unique driver identifier |
| driver_name | VARCHAR(100) | Driver's name |
| driver_status | VARCHAR(20) | Current driver status |
| Column | Type | Description |
|---|---|---|
| delivery_idPK | INTEGER | Unique delivery identifier |
| driver_id | INTEGER | Assigned driver identifier |
| delivery_status | VARCHAR(20) | Current delivery status |
| picked_up_at | TIMESTAMPTZ | Pickup timestamp |
| delivered_at | TIMESTAMPTZ | Delivery completion timestamp |