Moving average over 3 days: revenue, July 2025
Instructions
Consider completed deliveries (delivered_at is not NULL) whose delivered_at is on or after July 1, 2025 and strictly before August 1, 2025. For each calendar day (day = delivered_at::date) compute value, the sum of amount of such deliveries; every day of the period has deliveries. For each day output the moving average of value over the last 3 consecutive days, including the current one (moving_avg, rounded to 2 decimal places); on the first days of the period, where there are fewer previous days, average only the available ones. Columns: day, value, moving_avg. Sort by day ascending.
Hints
Each next one is more detailed and costs more
Query
Result
Click Run to see the query result, or Check to submit your solution.
Dataset schema
Table relationships
- N:1Many-to-one
deliveries.→restaurant_id restaurants.id - N:1Many-to-one
deliveries.→customer_id customers.id - N:1Many-to-one
deliveries.→courier_id couriers.id
Table data
Select a table in the diagram or list to view its rows.