Running Account Balance
Medium
Banking & HR Case Studies
Every transaction is a credit or a debit. Return each transaction with the running balance of its account after the transaction. Order by id.
Table schema
Transactions(id INT PRIMARY KEY, account_id INT, type VARCHAR(6), amount INT)Sample data
id | account_id | type | amount
1 | 1 | credit | 100
2 | 1 | debit | 30
3 | 1 | credit | 50
4 | 2 | credit | 20
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.