The analytics team wants a 3-transaction moving average of amounts for account_id = 1. For each transaction, compute the average of the current and two preceding transactions. Return transaction_date, amount, and moving_avg rounded to 2 decimals. Order by date.
Schema
🔑idINT
🔗account_idINT
transaction_dateTEXT
typeTEXT
amountREAL
balance_afterREAL
descriptionTEXT
reference_numberTEXT
postgresql
Run your query to see results
Press Ctrl + Enter to execute