Section: Distribution functions

Create deciles with NTILE(10)

sql
sql
SELECT customer_id,
       spend,
       NTILE(10) OVER (ORDER BY spend DESC) AS spend_decile
FROM customers;
Explanation

Great for segmentation, scoring, and rough percentile groupings.

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 Distribution functions
Leaderboard percent rank
Relative standing from 0 to 1.
OpenIn sheetsqlsame section
Find the 90th-percentile style cutoff
Identify rows at or above a cumulative threshold.
OpenIn sheetsqlsame section
Flag top quartile customers
Turn NTILE output into a simple segment label.
Build labeled score bands
Assign named score ranges using a window bucket.