What do PERCENT_RANK() and CUME_DIST() compute, and how do they differ from each other and from NTILE()?
Last updated
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.