Build a CTE of each customer's total spend (all orders). Then label them: Gold (≥ 10,000), Silver (≥ 4,000), else Bronze. Return name, total_spent, tier for customers who ordered.
14 rows with columns name, total_spent, tier — first 3 shown:
| # | |||
|---|---|---|---|
| 1 | Aarav Shah | 15138 | Gold |
| 2 | Diya Patel | 6096 | Silver |
| 3 | Kabir Singh | 13497 | Gold |
Run your code to see the output here.