Build a comprehensive customer financial summary using a CTE. First, compute the total balance across all accounts for each customer. Then, in the main query, join with customers to return first_name, last_name, total_balance, and the number of accounts. Only include customers with total_balance > 10000. Sort by 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