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

Outstanding Principal

Ignoring interest, return loans that still have a balance (principal minus payments above 0) together with the balance. Order by loan id.

Table schema

Loans(id INT PRIMARY KEY, customer VARCHAR(10), principal INT, annual_rate INT, months INT)
Payments(loan_id INT, amount INT, paid_on DATE)

Sample data

Loans
id | customer | principal | annual_rate | months
1 | Ann | 1000 | 12 | 6
2 | Bob | 2000 | 10 | 12
3 | Ann | 500 | 8 | 3

Payments
loan_id | amount | paid_on
1 | 400 | 2026-02-01
1 | 600 | 2026-03-01
2 | 500 | 2026-02-05
2 | 500 | 2026-03-05

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.