Loading the editor…
Measure how many days each delivered shipment took.
Network planning wants transit time for freight that actually arrived. In-transit and cancelled shipments have no completed duration.
Return id, destination_city, and transit_days. transit_days is the integer number of days from shipped_on to delivered_on. Keep delivered shipments only. Sort by transit_days descending, then id.
| id | name | city |
|---|---|---|
| 1 | Berlin Hub | Berlin |
| 2 | Lagos DC | Lagos |
| 3 | Rotterdam Port | Rotterdam |
| id | warehouse_id | destination_city | status | shipped_on | delivered_on |
|---|---|---|---|---|---|
| 1 | 1 | Paris | delivered | 2025-01-04 | 2025-01-06 |
| 2 | 1 | Warsaw | in_transit | 2025-02-11 | NULL |
| 3 | 2 | Accra | in_transit | 2025-02-12 | NULL |
Ctrl or Cmd + Enter runs the query. The database resets on every run.
Run the query to see rows from the sample database.
Next exercise: Headcount by department
Related: Three most recent deliveries, Age of in-transit shipments