Chapter 8 · Window Functions
18. 3-Month Moving Average of Order Value
Hard40 XPE-Commerce
Calculate a 3-month moving average of monthly order value. For each month, show the monthly average order value and a moving average that includes the current month and the two preceding months. Exclude cancelled orders. Round to 2 decimal places. Sort chronologically.
Tables
- PKidINT
- FKcustomer_id→ customers.idINT
- order_dateTEXT
- statusTEXT
- total_amountREAL
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.