Your question is Investigate Inventory Below Threshold. Start with the requirements and the four 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.
Cardinal Health distribution operations need to identify products whose projected end-of-day inventory fell below the minimum stock threshold during the most recent seven calendar days. The inventory snapshot is recorded before that day's outgoing shipments.
Write a PostgreSQL query using the latest inventory_date as the reporting date.
on_hand_quantity - outgoing shipment quantity for each product, distribution center, and day.warehouse_inventory contains daily snapshots for products P-1001, P-1002, and P-1003. outgoing_shipments contains shipments inside and outside the reporting window, including a shipment with a NULL quantity.
| Column | Type | Description |
|---|---|---|
| inventory_idPK | INT | Unique inventory snapshot row |
| product_id | VARCHAR(20) | Cardinal Health product identifier |
| center_id | VARCHAR(20) | Distribution center identifier |
| inventory_date | DATE | Inventory snapshot date |
| on_hand_quantity | INT | Units available before that day's shipments |
| minimum_stock_threshold | INT | Minimum acceptable inventory level |
| Column | Type | Description |
|---|---|---|
| shipment_idPK | INT | Unique outgoing shipment identifier |
| product_id | VARCHAR(20) | Shipped product identifier |
| center_id | VARCHAR(20) | Shipping distribution center |
| shipment_date | DATE | Shipment dispatch date |
| quantity | INT | Number of units shipped |
| Column | Type | Description |
|---|---|---|
| product_idPK | VARCHAR(20) | Product identifier |
| product_name | VARCHAR(150) | Product description |
| Column | Type | Description |
|---|---|---|
| center_idPK | VARCHAR(20) | Distribution center identifier |
| center_name | VARCHAR(150) | Distribution center name |