Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Running Account Balance

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.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.