Write a SQL query to analyze weekly hub performance at Veho by joining shipment, driver, and delivery tables to calculate on-time delivery rate, average delay, and retention by market. Use completed deliveries only. Driver retention means the percentage of drivers active in a market during a week who are also active in that same market during the immediately following week.
Output
- One row per delivery week and market, ordered by
week_start, then market.
- Columns:
week_start, market, shipment_count, on_time_rate, average_delay_minutes, and driver_retention_rate.
- Exclude shipments without completed deliveries. A NULL delay is ignored when calculating the average.