LAST_VALUE function
The LAST_VALUE window aggregation function returns the value of a specified expression for the last row in each OLAP window partition.
Syntax
Element | Description | Restrictions | Syntax |
---|---|---|---|
expression | Column name, alias, or constant expression | If expression references a column, the column must also be in the select list of the Projection clause | Column Expressions |
Usage
The return data type of the LAST_VALUE function is the data type of the specified expression. The result can be NULL. If IGNORE NULLS is specified, all rows where the expression value for the row evaluates to a NULL value are not considered in the calculation. If IGNORE NULLS is specified and all values in the OLAP window are NULL, the LAST_VALUE function returns the NULL value.
The RESPECT NULLS or IGNORE NULLS option can be specified either within the parentheses immediately following the expression, or outside the parentheses, but only one such specification is allowed.