Write a SQL query to analyze weekly shipment performance by warehouse, including on-time rate, late shipments, and average transit time for Verkada.
Use shipped date to determine the week. Exclude undelivered shipments from punctuality metrics, and exclude shipments without a promised date from on-time calculations.
warehouse_name, week_start, on_time_rate, late_shipments, and avg_transit_days.| Column | Type | Description |
|---|---|---|
| warehouse_idPK | INT | Unique warehouse identifier |
| warehouse_name | VARCHAR(100) | Warehouse display name |
| region | VARCHAR(50) | Geographic operating region |
| Column | Type | Description |
|---|---|---|
| shipment_idPK | INT | Unique shipment identifier |
| warehouse_id | INT | Warehouse that dispatched the shipment |
| shipped_at | DATE | Date the shipment left the warehouse |
| promised_at | DATE | Promised delivery date |
| delivered_at | DATE | Actual delivery date, or NULL if not delivered |