Marketing wants every customer in a spend quartile (1 = lowest spenders, 4 = highest), using total spend from spend_orders (order_id, customer_id, amount). Customers who spent exactly the same must land in the same quartile, even if that makes the quartiles unequal in size.
Define it this way: a customer's quartile is 4 × (the share of customers whose total spend is less than or equal to theirs), rounded up to a whole number. Only customers with orders are counted.
Columns: customer_id, total_spend, quartile (an integer 1–4). Sort by total_spend, then customer_id.