Segment customers into 4 tiers based on their total account balance using NTILE. Tier 1 is the top 25%% by balance, tier 4 is the bottom 25%%. Return first_name, last_name, total_balance, tier, and the count of customers in each tier (tier_size). Use a CTE for the tier assignment and a window function for tier_size. Order by tier ascending, total_balance descending.
Schema
🔑idINT
first_nameTEXT
last_nameTEXT
emailTEXT
phoneTEXTNULL
date_of_birthTEXT
cityTEXT
stateTEXT
countryTEXT
created_atTIMESTAMP
postgresql
Run your query to see results
Press Ctrl + Enter to execute