SQL Window Functions: Percentiles, Bucketing, and Distribution Analysis/Find the 90th-percentile style cutoff
Identify rows at or above a cumulative threshold.
Section: Distribution functions
Find the 90th-percentile style cutoff
sql
sql
WITH scored AS (
SELECT salary,
CUME_DIST() OVER (ORDER BY salary) AS cd
FROM employees
)
SELECT *
FROM scored
WHERE cd >= 0.90;Explanation
This is an intuitive pattern when exact percentile functions are unavailable or vary by dialect.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Distribution functions