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

Top Half of Spenders

Split customers into two equal groups by total spend (group 1 = higher spenders) using NTILE. Return customer, total spend and group, ordered by spend descending.

Table schema

Orders(id INT PRIMARY KEY, customer VARCHAR(10), amount INT)

Sample data

id | customer | amount
1 | Ann | 350
2 | Bob | 90
3 | Cy | 220
4 | Dee | 500

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.