What do PERCENT_RANK() and CUME_DIST() compute, and how do they differ from each other and from NTILE()?

Last updated 13 July 2026

  • PERCENT_RANK() is (rank - 1) / (total_rows - 1), ranging from 0 (first row) to 1 (last row).

  • CUME_DIST() is the fraction of rows with a value <= the current one, ranging from just above 0 up to 1.

  • NTILE(n) assigns discrete bucket numbers 1..n (e.g. quartiles), with earlier buckets getting extra rows. The other two are continuous fractions.

  • https://codewithmunnax.com/notes/sql/window-ntile-cume-dist-percent-rank
  • https://reintech.io/blog/understanding-sql-percent-rank-cume-dist-functions
All Advanced SQL interview questions