Chapter 6 · Subqueries
28. Loans with Interest Rate Above Their Type Average
Medium20 XPFinance
The pricing team wants to find loans whose interest rate exceeds the average rate for their loan type. Use a correlated subquery. Return loan id, loan_type, interest_rate, and the type_avg_rate rounded to 2 decimals. Sort by interest_rate descending. Limit to 25.
Tables
- PKidINT
- FKcustomer_id→ customers.idINT
- loan_typeTEXT
- principalREAL
- interest_rateREAL
- term_monthsINT
- start_dateTEXT
- statusTEXT
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.