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

# Overview

Window functions is a group of SQL functions, that operate on a partition or "window" of a result set, returning values for every row within that window. The following window functions and clauses are currently supported by Oxla:

### Window Functions

| <div align="left"> Function Name </div>                             | <div align="left"> Description </div>                                               |
| ------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| [COUNT](/sql-reference/sql-functions/window-functions/count)        | Counts all the rows or those specified by the given expression                      |
| [AVG](/sql-reference/sql-functions/window-functions/avg)            | Calculates the average (arithmetic mean) of a set of numeric values within a window |
| [SUM](/sql-reference/sql-functions/window-functions/sum)            | Calculates and returns the sum of values from the input column or expression values |
| [MIN](/sql-reference/sql-functions/window-functions/min)            | Computes the minimum value of an expression across a set of rows                    |
| [MAX](/sql-reference/sql-functions/window-functions/max)            | Computes the maximum value of an expression across a set of rows                    |
| [BOOL\_AND](/sql-reference/sql-functions/window-functions/bool-and) | Evaluates whether all values within a specified window of rows are true             |
| [BOOL\_OR](/sql-reference/sql-functions/window-functions/bool-or)   | Evaluates whether at least one value within a specified window of rows is true      |

### Ranking Functions

| **Function Name**                                                       | **Description**                                                                   |
| :---------------------------------------------------------------------- | :-------------------------------------------------------------------------------- |
| [ROW\_NUMBER](/sql-reference/sql-functions/window-functions/row-number) | Returns the current row index within its partition (beginning with 1)             |
| [RANK](/sql-reference/sql-functions/window-functions/rank)              | Calculates and returns the rank of a value within a specified group of values     |
| [DENSE\_RANK](/sql-reference/sql-functions/window-functions/dense-rank) | Calculates the percent rank of a value within a group and returns the result      |
| [NTILE](/sql-reference/sql-functions/window-functions/ntile)            | Divides an ordered data set into a specified number of approximately equal groups |

### Distribution Functions

| **Function Name**                                                           | **Description**                                                                       |
| :-------------------------------------------------------------------------- | :------------------------------------------------------------------------------------ |
| [CUME\_DIST](/sql-reference/sql-functions/window-functions/cume-dist)       | Calculates the cumulative distribution of a value within a set of values              |
| [PERCENT\_RANK](/sql-reference/sql-functions/window-functions/percent-rank) | Calculates and returns the percent rank of a value within a specified group of values |

### Value Functions

| **Function Name**                                                         | **Description**                                                                                                      |
| :------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------- |
| [FIRST\_VALUE](/sql-reference/sql-functions/window-functions/first-value) | Returns the first value in an ordered set of values within a specified partition                                     |
| [LAST\_VALUE](/sql-reference/sql-functions/window-functions/last-value)   | Returns the last value in an ordered set of values within a specified partition                                      |
| [NTH\_VALUE](/sql-reference/sql-functions/window-functions/nth-value)     | Returns a value from the nth row in an ordered partition of a result set                                             |
| [LAG](/sql-reference/sql-functions/window-functions/lag)                  | Returns the values for a row located at a defined offset, either above or below the current row within the partition |
| [LEAD](/sql-reference/sql-functions/window-functions/lead)                | Returns the values for a row located at a defined offset, either above or below the current row within the partition |

### Window Clause

| **Clause Name**                                  | **Description**                                                        |
| :----------------------------------------------- | :--------------------------------------------------------------------- |
| [OVER](/sql-reference/sql-clauses/over-window)   | Defines the window specification and is mandatory for window functions |
| [WINDOW](/sql-reference/sql-clauses/over-window) | Optional clause that defines one or more named window specifications   |

### Important Notes

There are a few essential things to remember when using window functions in Oxla:

* Verify that you can effectively use window functions alongside the `PARTITION BY`, `ORDER BY` and `FRAME` clauses as part of your window specification
* Ensure the window specification chaining is supported by executing the following command: `SELECT SUM(i0) OVER w2 FROM tb1 WINDOW w1 AS (PARTITION BY i1), w2 AS (w1 ROWS CURRENT ROW)`
* The `FRAME` clause of the window specification is restricted to the `ROWS` clause and does not include frame exclusion
