# DENSE_RANK() Function

### Description

Assigns ranks to rows within a partition, with no gaps in ranking values

### Syntax

```sql
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 with `ORDER BY` (and optional `PARTITION 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

```sql
SELECT
    id, DENSE_RANK() OVER (PARTITION BY department ORDER BY start_date) AS dr
FROM
    rippling.employee.Employee;
```

Source: https://developer.rippling.com/documentation/rippling-platform/transformations/sql-reference/dense_rank

> For the complete documentation index, see [llms.txt](https://developer.rippling.com/llms.txt). Public pages have a Markdown version at the same URL with .md added.
