Skip to main content
All Problems
medium0% acceptance

3-Order Moving Average Per Customer

Calculate a 3-order moving average of total_amount for each customer. The moving average should include the current order and the two preceding orders (by date). Return customer_id, order_date, total_amount, and moving_avg_3 (rounded to 2 decimal places).

Schema

🔑idINT
🔗customer_idINT
order_dateTEXT
statusTEXT
total_amountREAL
postgresql

Run your query to see results

Press Ctrl + Enter to execute