Chapter 4 · Aggregations
63. Interest Collected per Loan Type
Medium20 XPFinance
The finance department wants to know how much interest has been collected for each loan type. Join loans to payments and sum the interest_paid column per loan_type. Return loan_type, the number of payments (payment_count), and total_interest_collected rounded to 2 decimals. Sort by total_interest_collected 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.