Skip to main content
All Problems
hard0% acceptance

Top 3 Accounts by Balance Per Type

Find the top 3 highest-balance active accounts for each account type. Use ROW_NUMBER() in a CTE, then filter for the top 3. Return account_type, id, balance, and the row number (rn). Sort by account_type, rn.

Schema

🔑idINT
🔗customer_idINT
account_typeTEXT
balanceREAL
currencyTEXT
opened_atTEXT
statusTEXT
postgresql

Run your query to see results

Press Ctrl + Enter to execute