Window
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 | Description |
---|---|
COUNT | Counts all the rows or those specified by the given expression. |
DENSE_RANK | Calculates the percent rank of a value within a group and returns the result |
LAG | Returns the values for a row located at a defined offset, either above or below the current row within the partition |
LEAD | Returns the values for a row located at a defined offset, either above or below the current row within the partition |
PERCENT_RANK | Calculates and returns the percent rank of a value within a specified group of values |
RANK | Calculates and returns the rank of a value within a specified group of values |
ROW_NUMBER | Returns the current row index within its partition (beginning with 1) |
SUM | Calculates and returns the sum of values from the input column or expression values |
Window Clauses | Description |
---|---|
OVER | Defines the window specification and is mandatory for window functions |
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
andFRAME
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 theROWS
clause and does not include frame exclusion