Problem Statement
When would you use PERCENT_RANK or CUME_DIST instead of DENSE_RANK for analytics?
Explanation
Use PERCENT_RANK or CUME_DIST when you need a normalized score between zero and one to compare positions across groups with different sizes. These functions express relative standing, which is ideal for dashboards and thresholds like top five percent.
DENSE_RANK gives integer ranks and is best when you need discrete positions or to filter top N by rank.
Code Solution
SolutionRead Only
PERCENT_RANK() OVER (PARTITION BY category ORDER BY score) AS pr -- 0 for first, 1 for last
