Menu
mediumBoost · window

Running balance for each e-wallet

A transactions table logs top-ups (positive amounts) and payments (negative amounts) for e-wallet accounts. Support needs to see the running balance after each transaction, per wallet, so they can spot the exact transaction where a wallet first went negative.

Return wallet_id, txn_date, amount and running_balance (the cumulative sum of amount for that wallet, up to and including that row), ordered by wallet_id then txn_date.

Schema

wallet_txns
txn_idINT
wallet_idTEXT
txn_dateDATE
amountNUMERIC

Example input

wallet_txns
↑ Read the question

Keep going

Company names are trademarks of their respective owners, used here only to describe practice material. mahir_data is not affiliated with, endorsed by, or sponsored by any company named on this site. Terms.