Chapter 4 · Aggregations
65. Customers Holding Multiple Account Types
Medium20 XPFinance
Find customers who hold more than one distinct type of account (e.g., both checking and savings). Return customer_id, the customer's first_name, last_name, and the count of distinct account types (type_count). Only include customers with type_count > 1. Order by type_count descending, then last_name ascending.
Tables
- PKidINT
- first_nameTEXT
- last_nameTEXT
- emailTEXT
- phoneTEXT
- date_of_birthTEXT
- cityTEXT
- stateTEXT
- countryTEXT
- created_atTIMESTAMP
- PKidINT
- FKcustomer_id→ customers.idINT
- account_typeTEXT
- balanceREAL
- currencyTEXT
- opened_atTEXT
- 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.