Skip to main content
All Problems
hard0% acceptance

Per-Customer 3-Transaction Moving Average

For each customer, compute a 3-transaction moving average of withdrawal amounts. Return first_name, last_name, transaction_date, amount, and moving_avg_3 (rounded to 2 decimals). The moving average should consider the current and two preceding withdrawal transactions ordered by transaction id. Only include withdrawal transactions. Order by last_name, transaction_date.

Schema

🔑idINT
first_nameTEXT
last_nameTEXT
emailTEXT
phoneTEXTNULL
date_of_birthTEXT
cityTEXT
stateTEXT
countryTEXT
created_atTIMESTAMP
postgresql

Run your query to see results

Press Ctrl + Enter to execute