Your question is Dasher Waiting Time Query. Start with the requirements and the one table 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.
DoorDash operations wants to measure how long each Dasher spent in the waiting_for_order status during a reporting period. Status logs represent status changes, so each row remains active until the next status event for that Dasher.
Write a PostgreSQL query for the period from 2025-02-01 00:00:00 through 2025-02-02 12:00:00.
waiting_for_order, clipping intervals to the reporting boundaries.dasher_id.| Column | Type | Description |
|---|---|---|
| log_idPK | INT | Unique status log identifier |
| dasher_id | INT | DoorDash Dasher identifier |
| status | VARCHAR(40) | Dasher status beginning at status_at |
| status_at | TIMESTAMP | Timestamp when the status began |
| notes | TEXT | Optional operational note |