Description
Assigns ranks to rows within a partition, with no gaps in ranking values
Syntax
DENSE_RANK ( ) OVER ( [ partition_by_clause ] order_by_clause )
Notes
- If two or more rows have the same rank value in the same partition, each of those rows will receive the same rank
- Include an
OVER (...)clause withORDER BY(and optionalPARTITION BY) when using this as a window function.
Rewrite
Use QUALIFY to filter on window expression results; do not use window functions in WHERE.
Example
SELECT
id, DENSE_RANK() OVER (PARTITION BY department ORDER BY start_date) AS dr
FROM
rippling.employee.Employee;