We use analytics and advertising cookies to understand how the site is used and whether our ads on Facebook and Instagram work. They are set only if you accept. See our Privacy Policy for details.
name, total spend as total_spent, and the rank as spend_rank (1 = highest spender) using a window function so ties share a rank. Include only customers with orders. Order by spend_rank, then name.