Chapter 9 · Interview Level
31. Average Delivery Time by Carrier
Hard40 XPE-Commerce
The logistics team wants to compare carrier performance. Calculate the average number of days between order_date and delivery_date for each carrier, but only for delivered shipments. Return the carrier, total delivered shipments, and average delivery days (rounded to 1 decimal), sorted by average delivery days (fastest first).
Tables
- PKidINT
- FKcustomer_id→ customers.idINT
- order_dateTEXT
- statusTEXT
- total_amountREAL
- PKidINT
- FKorder_id→ orders.idINT
- shipping_dateTEXT
- delivery_dateTEXT
- carrierTEXT
- tracking_numberTEXT
- statusTEXT
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.