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.
OpenIn sheetsqlsame section
Create deciles with NTILE(10)
Bucket rows into 10 groups.
Leaderboard percent rank
Relative standing from 0 to 1.
Find the 90th-percentile style cutoff
Identify rows at or above a cumulative threshold.