Chapter 4 · Aggregations
62. Branch with the Most Customer Accounts
Medium20 XPFinance
Management wants to know which branch city has the most customer accounts. Count the number of accounts per branch city by joining customers to accounts and matching customer city to branch city. Return city, branch name, and account_count. Sort by account_count descending. Limit to 10.
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
- nameTEXT
- cityTEXT
- stateTEXT
- manager_nameTEXT
- opened_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.