Write a SQL query to analyze weekly order volume, on-time delivery rate, and backorders by customer segment for Bunzl’s operations.
Use the orders, customers, and deliveries tables. Include all order weeks and treat missing customer segments as Unknown.
Output
- One row per order week and customer segment.
- Columns:
week_start, customer_segment, order_volume, on_time_delivery_rate, and backorder_count.
- Include delivery rate as a percentage of delivered orders, rounded to two decimals, and return
NULL when no orders were delivered.
- Sort by
week_start, then customer_segment.