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

(1)
LAST_VALUE function

1  LAST_VALUE
2.1  ( expression )
2.2.1 
2.2.2.1 RESPECT NULLS
2.2.2.1 IGNORE NULLS
2.1  ( expression
2.2.1 RESPECT NULLS
2.2.1 IGNORE NULLS
2.1 ) %OVER clause for aggregation functions1
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.