Chapter 5 · JOINs
45. Customer Total Balance with Branch Info
Medium20 XPFinance
Create a report showing each customer's total account balance alongside their local branch info. Join customers to accounts (summing balance) and to branches (on city). Return first_name, last_name, city, branch name, and total_balance. Sort by total_balance descending. Limit to 25.
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.