Section: Ranking functions

Calculate percent rank

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

Great for percentile-style reporting without manual math.

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
Cumulative distribution
Fraction of rows at or below the current row.
OpenIn sheetsqlsame section
Get the latest row per group
Use ROW_NUMBER in a subquery or CTE.