The credit risk team needs to find customers who have more than one active loan. Use a subquery with GROUP BY and HAVING to identify qualifying customer_ids, then join to customers for details. Return first_name, last_name, and the number of active loans (active_loan_count). Sort by active_loan_count descending.
Schema
🔑idINT
first_nameTEXT
last_nameTEXT
emailTEXT
phoneTEXTNULL
date_of_birthTEXT
cityTEXT
stateTEXT
countryTEXT
created_atTIMESTAMP
postgresql
Run your query to see results
Press Ctrl + Enter to execute