Chapter 5 · JOINs
38. Number of Cards Per Customer
Medium20 XPFinance
The card operations team wants to know how many cards each customer has. Return first_name, last_name, and card_count. Include customers with zero cards. Sort by card_count descending, then last_name.
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
- PKidINT
- FKaccount_id→ accounts.idINT
- card_numberTEXT
- card_typeTEXT
- expiry_dateTEXT
- statusTEXT
- credit_limitREAL
- issued_atTEXT
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.