Outstanding Principal
Medium
Loans & Repayments
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.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.