NTILE, PERCENT_RANK, CUME_DIST

  • NTILE(n): Divides rows into n buckets.
  • PERCENT_RANK(): Shows relative rank (0 to 1).
  • CUME_DIST(): Shows cumulative distribution of value in partition.
SELECT employee_id, salary,
       NTILE(4) OVER (ORDER BY salary) AS quartile
FROM employees;