Chapter 8 · Window Functions
34. Percent Rank of Account Balances
Hard40 XPFinance
The analytics team wants to see what percentile each account's balance falls in within its account type. Use PERCENT_RANK() to compute the percentile. Return account_type, balance, and balance_percentile rounded to 2 decimals. Only include active accounts. Sort by account_type, then balance DESC.
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.