Chapter 5 · JOINs
47. Loan Payment Progress Tracker
Medium20 XPFinance
For each active loan, show the loan id, principal, total amount paid so far (total_paid), and the percentage of the principal that has been paid (pct_paid, rounded to 2 decimal places). Join loans to payments. Only include loans with status 'active'. Order by pct_paid descending.
Tables
- PKidINT
- FKcustomer_id→ customers.idINT
- loan_typeTEXT
- principalREAL
- interest_rateREAL
- term_monthsINT
- start_dateTEXT
- statusTEXT
- PKidINT
- FKloan_id→ loans.idINT
- payment_dateTEXT
- amountREAL
- principal_paidREAL
- interest_paidREAL
- remaining_balanceREAL
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.