RienSQL
TASK #162 · Hard · Delivery Hero

Monthly Avg Delivery Time (window functions)

Your brief
Write a query that for every month returns mth (month number) and avg_minutes — the average delivery time of orders that month, rounded to two decimals.

Use window functions (AVG(...) OVER (PARTITION BY ...)) instead of GROUP BY, removing duplicates with DISTINCT. Sort the result by mth.
Expected columnsmth avg_minutesDelivery Hero
SQL editor
SQLite
Ctrl / ⌘ + ↵
Result

Write a query and run it to see the results.

Schema
citiescity_id, city_name, country
customerscustomer_id, name, city_id
restaurantsrestaurant_id, name, city_id
ordersorder_id, customer_id, restaurant_id, order_placed, order_delivered
order_itemsitem_id, order_id, product_name