TASK #175 · Hard · N26Running Balance over Transactions
Your brief
Build a "running-balance statement" for every customer from the
transactions table.
transfer_in rows add money to the balance (sign +); card_purchase, transfer_out and atm_withdrawal remove it (sign −).
Write a query that returns transaction_id, customer_id, transaction_at, transaction_type, amount and running_balance — the customer's balance after this transaction, computed as a running total over transaction_at.
Sort by customer_id, then by transaction_at.
transfer_in rows add money to the balance (sign +); card_purchase, transfer_out and atm_withdrawal remove it (sign −).
Write a query that returns transaction_id, customer_id, transaction_at, transaction_type, amount and running_balance — the customer's balance after this transaction, computed as a running total over transaction_at.
Sort by customer_id, then by transaction_at.
Ctrl / ⌘ + ↵
Result
Write a query and run it to see the results.
Schema
customerscustomer_id, name, country, signup_datetransactionstransaction_id, customer_id, transaction_type, amount, merchant_category, transaction_at