LAST_VALUE()

Aggregate. Returns the last value from an ordered set of values. LAST_VALUE() is an alias for the LAST() function in the Sybase CEP compiler.

Syntax

LAST_VALUE( expression )

Parameters
expression The expression on which to determine the last value in an ordered set.

LAST_VALUE returns the last value in an ordered set of values. If the last value in the set is null, then the function returns NULL unless you specify IGNORE NULLS. If you specify IGNORE NULLS, then LAST_VALUE returns the last non-null value in the set, or NULL if all values are null.

You cannot use LAST_VALUE or any other analytic function as an expression. That is, you cannot nest analytic functions, but you can use other built-in function expressions for expression.

Sybase extension.

The following example computes the tick-by-tick open, close, minimum, and maximum values for trades for a one-minute interval:

INSERT INTO OutOpenCloseMinMax2
SELECT 

      LAST_VALUE(Price) as OpenPrice,
      FIRST_VALUE(Price IGNORE NULLS) as OpenPrice2,
      GETTIMESTAMP(LAST_VALUE(MyWindow)) as t1

FROM 
    MyWindow