Chapter 6 · Subqueries
32. Account Type Balance Share
Medium20 XPFinance
Calculate the percentage of total bank balance held in each account type. Return account_type, type_total (sum of balances for that type), and pct_of_total (rounded to 2 decimals). Use a subquery to get the overall total. Order by pct_of_total descending.
Tables
- 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.