Customers With Several Open Loans
Medium
Loans & Repayments
A loan is open when payments are less than its principal. Return customers with more than one open loan, and how many.
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
4 | Bob | 300 | 5 | 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.