Write SQL and Python, run instantly in your browser, and track your progress.
You are an Inventory Analyst at Amazon. Supply planning needs to flag backorderable items where available inventory is running low. Provide the inventory identifier, product identifier, warehouse, on-hand units, and reserved units. Sort by the fewest available units first (on-hand minus reserved); break ties by the smallest identifier.
| Column Name | Type |
|---|---|
| inventory_id | INTEGER |
| warehouse_code | TEXT |
| product_id | INTEGER |
| on_hand |
You are an Inventory Analyst at Amazon. Supply planning needs to flag backorderable items where available inventory is running low. Provide the inventory identifier, product identifier, warehouse, on-hand units, and reserved units. Sort by the fewest available units first (on-hand minus reserved); break ties by the smallest identifier.
| Column Name | Type |
|---|---|
| inventory_id | INTEGER |
| warehouse_code | TEXT |
| product_id | INTEGER |
| on_hand |
| INTEGER |
| INTEGER |
| reserved | INTEGER |
| reserved | INTEGER |
| backorderable | INTEGER |
| backorderable | INTEGER |
| last_restock_date | TEXT |
| last_restock_date | TEXT |
| inventory_id | warehouse_code | product_id | on_hand | reserved | backorderable | last_restock_date |
|---|---|---|---|---|---|---|
| 1 | W2-Chicago | 1 | 57 | 7 | 0 | 2025-09-27 |
| 2 |
| inventory_id | warehouse_code | product_id | on_hand | reserved | backorderable | last_restock_date |
|---|---|---|---|---|---|---|
| 1 | W2-Chicago | 1 | 57 | 7 | 0 | 2025-09-27 |
| 2 |
| inventory_id | product_id | warehouse_code | on_hand | reserved |
|---|---|---|---|---|
| 105 | 47 | W3-Atlanta | 3 | 1 |
| 87 | 39 | W3-Atlanta | 11 | 6 |
| inventory_id | product_id | warehouse_code | on_hand | reserved |
|---|---|---|---|---|
| 105 | 47 | W3-Atlanta | 3 | 1 |
| 87 | 39 | W3-Atlanta | 11 | 6 |
2 rows returned.
2 rows returned.
1. Output Columns: - inventory ID - product ID - warehouse code - on-hand - reserved 2. Filtering: - Include only backorderable items (backorderable = 1) - Available units (on_hand - reserved) must be <= 5 3. Ordering: - Sort by available units (ascending) - Tie-breaker: inventory_id (ascending)
1. Output Columns: - inventory ID - product ID - warehouse code - on-hand - reserved 2. Filtering: - Include only backorderable items (backorderable = 1) - Available units (on_hand - reserved) must be <= 5 3. Ordering: - Sort by available units (ascending) - Tie-breaker: inventory_id (ascending)
| W3-Atlanta |
| W3-Atlanta |
| 2 |
| 2 |
| 3 |
| 3 |
| 3 |
| 3 |
| 0 |
| 0 |
| 2025-11-15 |
| 2025-11-15 |
| 3 | W2-Chicago | 2 | 62 | 6 | 0 | 2025-11-05 |
| 3 | W2-Chicago | 2 | 62 | 6 | 0 | 2025-11-05 |
| 4 | W1-Seattle | 2 | 43 | 8 | 0 | 2025-09-10 |
| 4 | W1-Seattle | 2 | 43 | 8 | 0 | 2025-09-10 |
| 5 | W3-Atlanta | 3 | 66 | 6 | 1 | 2025-10-17 |
| 5 | W3-Atlanta | 3 | 66 | 6 | 1 | 2025-10-17 |