EasyWindow Functions
Rank all products by price globally
The query
SQL
SELECT
name,
price,
RANK() OVER (ORDER BY price DESC) AS price_rank,
DENSE_RANK() OVER (ORDER BY price DESC) AS dense_rank,
ROUND(PERCENT_RANK() OVER (ORDER BY price) * 100, 1) AS percentile
FROM products
WHERE is_active = TRUE
ORDER BY price_rank;Note
“PERCENT_RANK returns 0.0 to 1.0 (0% to 100%). Multiply by 100 for human-readable percentile.