We use cookies for site analytics. Accept to help us understand how the site is used. 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.