Part 94: Tile Ranking with NTILE() for Percentiles & Buckets
NTILE(n) divides an ordered partition into n approximately equal buckets or tiers.
1. Quartile Analysis (Dividing into 4 Tiers)
SELECT
customer_name,
total_spend,
NTILE(4) OVER (ORDER BY total_spend DESC) AS spend_quartile
FROM customer_spends;
- Quartile 1: Top 25% highest spenders (VIPs).
- Quartile 4: Bottom 25% spenders.
Key Takeaways
- Use
NTILEfor cohort segmentation, percentiles, and tiered pricing bands.
In Part 95, we master Value Navigation Functions: LAG() and LEAD()!

