TASK #210 · Medium · GlovoLate Delivery Rate by City
Your brief
Glovo promises the customer delivery within promised_minutes minutes. An
order is late if delivered_at is strictly later than created_at +
promised_minutes minutes; delivery exactly on time is not late.
Write a query that, over delivered orders (status = 'delivered'), returns city (the store's city from stores), delivered_orders (the number of delivered orders) and late_pct (the percentage of late ones among them, rounded to two decimals). Sort by late_pct descending and, on ties, by city alphabetically.
Write a query that, over delivered orders (status = 'delivered'), returns city (the store's city from stores), delivered_orders (the number of delivered orders) and late_pct (the percentage of late ones among them, rounded to two decimals). Sort by late_pct descending and, on ties, by city alphabetically.
Ctrl / ⌘ + ↵
Result
Write a query and run it to see the results.
Schema
storesstore_id, store_name, category, city, x, ycourierscourier_id, courier_name, city, vehicleordersorder_id, store_id, courier_id, status, created_at, promised_minutes, delivered_at, courier_start_x, courier_start_y, dropoff_x, dropoff_y, order_total