Skip to content
SQLSimplified
Data AnalystQuestion 38 of 57

Calculating Moving Averages

Problem

To smooth out seasonal sales fluctuations, the sales team wants a 3-day moving average of order amounts. Write a query that outputs concept with the value: "A moving average is calculated using window frame bounds: AVG(amount) OVER (ORDER BY order_date ROWS BETWEEN 2 PRECEDING AND CURRENT ROW)."

Database Schema

This problem acts as a scratchpad. You will write your own DDL/DML or conceptual queries, so there is no predefined schema.

Try It

Loading playground environment...

Hint

Solution