Skip to main content
All Problems
hard0% acceptance

Running Balance After Each Transaction

For account_id = 1, compute a running sum of transaction amounts ordered by transaction_date. Return the row number, transaction_date, type, amount, and running_total using a SUM window function with an appropriate frame (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW). Sort by transaction_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