Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Customer Spend Tiers

Divide customers into three tiers by total spend: tier 1 holds the top third of spenders, tier 3 the lowest third. Return customer_id, total_spent and tier ordered by total_spent descending.

Table schema

Orders(id INT PRIMARY KEY, customer_id INT, amount INT)

Sample data

id | customer_id | amount
1 | 1 | 60
2 | 2 | 50
3 | 3 | 40
4 | 4 | 30
5 | 5 | 20
6 | 6 | 10

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.