Loading section...

NTILE and Bucketing

Concepts: sqlNtile

NTILE Fundamentals Basic NTILE Usage Consider a customer segmentation scenario. A marketing team wants to divide customers into four spending tiers to target campaigns differently. The top quartile gets exclusive offers, the bottom quartile gets re-engagement campaigns. With 8 rows divided into 4 groups, each group gets exactly 2 rows. Quartile 1 contains the highest spenders and quartile 4 the lowest. This is a clean division because 8 divides evenly by 4. Handling Remainders The rule is simple: if there are R remainder rows, the first R buckets each get one extra row. This ensures the difference in group size is never more than one. Deciles and Percentiles Employees in decile 10 are in the top 10 percent of salaries. Those in decile 1 are in the bottom 10 percent. This is far more inform