Section: Distribution functions

Leaderboard percent rank

sql
sql
SELECT player_id,
       score,
       PERCENT_RANK() OVER (ORDER BY score) AS pct_rank
FROM leaderboard;
Explanation

A convenient way to label records as top 5%, top 10%, and so on.

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
Create deciles with NTILE(10)
Bucket rows into 10 groups.
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.