Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. PERCENT_RANK vs CUME_DIST

SQL · Window Functions

PERCENT_RANK vs CUME_DIST

Mediumsql-24
percent_rankcume_distdistribution

Question

What is the difference between PERCENT_RANK and CUME_DIST?

Solution

PERCENT_RANK() measures relative rank.

Formula:

(rank - 1) / (number_of_rows - 1)

It ranges from 0 to 1 when there is more than one row.

CUME_DIST() tells you the proportion of rows whose ordering value is less than or equal to the current row's value.

Simple difference:

> PERCENT_RANK = position based on rank > CUME_DIST = percentage of rows at or below this value

Ties can make their results noticeably different.

🎯 Put this concept into practice

Solidify this answer with real hands-on interview drills in the browser studio.

Open related drill →
PreviousNext