Write a SQL query to analyze warehouse performance at Sysco by joining shipment, inventory, and labor tables to calculate cases per hour and dock-to-stock time by facility. Use the supplied tables and include facilities appearing in any source table. Handle missing values and zero labor hours without causing errors.
facility_id, shipped_cases, labor_hours, cases_per_hour, and avg_dock_to_stock_minutes.facility_id ascending, and return NULL when a metric cannot be calculated.| Column | Type | Description |
|---|---|---|
| shipment_idPK | INT | Unique shipment identifier |
| facility_id | VARCHAR(10) | Sysco warehouse facility identifier |
| shipped_at | TIMESTAMP | Shipment completion timestamp |
| cases_shipped | INT | Number of cases shipped |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique inventory event identifier |
| facility_id | VARCHAR(10) | Sysco warehouse facility identifier |
| received_at | TIMESTAMP | Timestamp when inventory arrived at the dock |
| stocked_at | TIMESTAMP | Timestamp when inventory was placed into stock |
| cases_received | INT | Number of cases received |
| Column | Type | Description |
|---|---|---|
| shift_idPK | INT | Unique labor shift identifier |
| facility_id | VARCHAR(10) | Sysco warehouse facility identifier |
| shift_date | DATE | Date of the labor shift |
| hours_worked | DECIMAL(6,2) | Labor hours recorded for the shift |