Window Functions

Percent Rank and Cumulative Distribution

Senior Data Analyst
March 8, 2026
5 min read

The Statistical View

Data science needed a more nuanced ranking: not just 1st, 2nd, 3rd, but a percentage showing relative standing.

The Functions

  • `PERCENT_RANK()`: Relative rank as a percentage (0 to 1).
  • `CUME_DIST()`: Cumulative distribution (what % of rows are at or below this value?).
  • SELECT

    name, score,

    PERCENT_RANK() OVER (ORDER BY score) AS pct_rank,

    CUME_DIST() OVER (ORDER BY score) AS cume_dist

    FROM test_scores;

    Pro Tip

    These are the SQL equivalents of statistical percentile functions. Great for identifying outliers or benchmarking performance.

    *Day 68: Filtering Window Function Results.*

    Ready to put your knowledge into practice?

    Join SQL Mastery and learn through interactive exercises.