Section: Ranking functions

Cumulative distribution

sql
sql
SELECT player_id,
       score,
       CUME_DIST() OVER (ORDER BY score) AS cume_dist
FROM leaderboard;
Explanation

`CUME_DIST` answers what share of rows are less than or equal to this one.

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 Ranking functions
ROW_NUMBER
Unique sequence with no ties.
OpenIn sheetsqlsame section
RANK
Tied rows share rank and leave gaps.
OpenIn sheetsqlsame section
DENSE_RANK
Tied rows share rank without gaps.
OpenIn sheetsqlsame section
Split rows into quartiles with NTILE
Bucket ordered rows into four groups.
OpenIn sheetsqlsame section
Calculate percent rank
Relative position from 0 to 1.
OpenIn sheetsqlsame section
Get the latest row per group
Use ROW_NUMBER in a subquery or CTE.