> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sdf.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Window Functions

## `conditional_change_event`

Returns the event window number of this row in the window based on whether the argument expression on the current row differs from that on the previous row
*Supported Signatures*

```sql theme={null}
function conditional_change_event($1) returns decimal(38, 0)
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/conditional_change_event)

## `conditional_true_event`

Returns the event window number of this row in the window based on the result of the boolean argument expression
*Supported Signatures*

```sql theme={null}
function conditional_true_event(boolean) returns decimal(38, 0)
function conditional_true_event(decimal(38, 0)) returns decimal(38, 0)
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/conditional_true_event)

## `cume_dist`

Returns the cumulative distribution of a row in the window
*Supported Signatures*

```sql theme={null}
function cume_dist() returns double
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/cume_dist)

## `dense_rank`

Returns the dense rank of a row in the window
*Supported Signatures*

```sql theme={null}
function dense_rank() returns decimal(38, 0)
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/dense_rank)

## `first_value`

Returns the first value of a column
*Supported Signatures*

```sql theme={null}
function first_value($1) returns $1
function first_value($1, integer) returns $1
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/first_value)

## `lag`

Returns the value of an expression at the specified offset row
*Supported Signatures*

```sql theme={null}
function lag($1) returns $1
function lag($1, decimal(38, 0)) returns $1
function lag($1, decimal(38, 0), $1) returns $1
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/lag)

## `last_value`

Returns the last value of a column
*Supported Signatures*

```sql theme={null}
function last_value($1) returns $1
function last_value($1, integer) returns $1
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/last_value)

## `lead`

Returns the value of an expression at the specified offset row
*Supported Signatures*

```sql theme={null}
function lead($1) returns $1
function lead($1, decimal(38, 0)) returns $1
function lead($1, decimal(38, 0), $1) returns $1
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/lead)

## `nth_value`

Returns the first value of a column
*Supported Signatures*

```sql theme={null}
function nth_value($1, decimal(38, 0)) returns $1
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/nth_value)

## `ntile`

Number of groups (ntiles) per window
*Supported Signatures*

```sql theme={null}
function ntile(decimal(38, 0)) returns decimal(38, 0)
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/ntile)

## `percent_rank`

Returns the percent rank of a row in the window
*Supported Signatures*

```sql theme={null}
function percent_rank() returns double
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/percent_rank)

## `rank`

Returns the rank of a row in the window
*Supported Signatures*

```sql theme={null}
function rank() returns decimal(38, 0)
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/rank)

## `ratio_to_report`

Returns a cumulative ratio\_to\_report of a column
*Supported Signatures*

```sql theme={null}
function ratio_to_report(decimal(38, 0)) returns decimal(38, 0)
function ratio_to_report(decimal(38, 0), decimal(38, 0)) returns decimal(38, 0)
function ratio_to_report(double) returns double
function ratio_to_report(double, decimal(38, 0)) returns double
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/ratio_to_report)

## `row_number`

Returns the position of this row in the window
*Supported Signatures*

```sql theme={null}
function row_number() returns decimal(38, 0)
```

[🔗 Official Documentation](https://docs.snowflake.com/en/sql-reference/functions/row_number)
