Write a SQL query using window functions to identify the top-performing delivery hubs based on order volume and delivery time for Licious last-mile operations.
Use completed orders from January 2025. Calculate each hub's order volume and average delivery time, rank hubs using the sum of their volume rank and delivery-time rank, and return the three highest-performing hubs.
hub_code, hub_name, order_volume, avg_delivery_minutes, volume_rank, delivery_time_rank, performance_score, and performance_rank.performance_rank, then hub_code.| Column | Type | Description |
|---|---|---|
| hub_idPK | INT | Unique delivery hub identifier |
| hub_code | VARCHAR(20) | Short operational code for the hub |
| hub_name | VARCHAR(100) | Delivery hub name |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| hub_id | INT | Hub assigned to the order |
| order_status | VARCHAR(30) | Current order delivery status |
| dispatched_at | TIMESTAMP | Timestamp when the order left the hub |
| delivered_at | TIMESTAMP | Timestamp when the order was delivered |