Your question is Goods at a Specific Time. 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.
Flexport needs a point-in-time inventory view across its warehouse network. Given load and unload actions, write a PostgreSQL query that returns the amount of goods at every Flexport warehouse as of 2026-06-15 23:59:59+00.
LOAD quantities as positive and UNLOAD quantities as negative.0 goods on hand.warehouse_id ascending.| Column | Type | Description |
|---|---|---|
| warehouse_idPK | INTEGER | Unique warehouse identifier |
| facility_name | VARCHAR(100) | Flexport warehouse name |
| city | VARCHAR(80) | Warehouse city |
| Column | Type | Description |
|---|---|---|
| action_idPK | INTEGER | Unique inventory action identifier |
| warehouse_id | INTEGER | Warehouse receiving the action |
| action_type | VARCHAR(20) | Inventory action, such as LOAD or UNLOAD |
| quantity | INTEGER | Number of goods affected by the action |
| occurred_at | TIMESTAMPTZ | Timestamp when the action occurred |