PERCENT_RANK calculates the relative rank of a row within a window, producing a value between 0 and 1.
Relative ranking helps compare performance against other records rather than relying only on absolute values.
Calculate each employee's salary position within the company.
SELECT
e.EmployeeName,
d.DepartmentName,
e.Salary,
PERCENT_RANK() OVER (
ORDER BY e.Salary
) AS SalaryPercentRank
FROM Employees e
INNER JOIN Departments d
ON e.DepartmentID = d.DepartmentID;
Used in compensation analysis, performance management, customer scoring, and benchmarking.
- PERCENT_RANK returns a value from 0 to 1.
- ORDER BY defines ranking.
- The lowest ordered value normally receives 0.
- The highest normally receives 1.
- Useful for relative-position analysis.
What does PERCENT_RANK return?
It returns the relative rank of a row as a value between 0 and 1.
How is PERCENT_RANK different from RANK?
RANK returns integer ranking positions, while PERCENT_RANK expresses relative position as a proportion.