Assign named score ranges using a window bucket.
Section: Segmentation patterns
Build labeled score bands
sql
sql
WITH scored AS (
SELECT user_id,
engagement_score,
NTILE(5) OVER (ORDER BY engagement_score DESC) AS bucket
FROM user_scores
)
SELECT user_id,
engagement_score,
CASE bucket
WHEN 1 THEN 'elite'
WHEN 2 THEN 'high'
WHEN 3 THEN 'medium'
WHEN 4 THEN 'low'
ELSE 'very_low'
END AS engagement_band
FROM scored;Explanation
Often easier to explain to stakeholders than raw percentiles.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Segmentation patterns
Flag top quartile customers
Turn NTILE output into a simple segment label.
Find the 90th-percentile style cutoff
Identify rows at or above a cumulative threshold.