SQL · Pattern 10 — Window Functions
DENSE_RANK()
Ranks rows without gaps after ties.
Source data — Pattern 10: Window Functions
All queries run against the shared employees table (see schema.sql). This pattern introduces a sales table to demonstrate window functions including ranking, navigation, running totals, moving averages and window aggregates.


What it does
Ranks rows without gaps after ties.
Problem
Assign dense ranks based on sales.
SELECT *,
DENSE_RANK() OVER(ORDER BY sales_amount DESC) AS result
FROM sales;
Result
