Loading the editor…
Show how many days each in-transit shipment has been open as of 15 March 2025.
The control tower ages open freight against a fixed as-of date so the morning report does not change just because the query runs later.
Return id, destination_city, and days_open. days_open is the integer day difference from shipped_on to 2025-03-15. Keep status in_transit. Sort by days_open 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: Top vendor in each category
Related: Days from ship to delivery, Shipments still in transit