FIRST_VALUE()

Aggregate. Returns first value from an ordered set of values. FIRST_VALUE() is an alias for the FIRST() function in the Sybase CEP compiler.

Syntax

FIRST_VALUE( expression [IGNORE NULLS] )

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

FIRST_VALUE returns the first value in an ordered set of values. If the first value in the set is null, then the function returns NULL unless you specify IGNORE NULLS. If you specify IGNORE NULLS, then FIRST_VALUE returns the first non-null value in the set, or NULL if all values are null. You cannot use FIRST_VALUE or any other analytic function for 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 OutOpenCloseMinMax
SELECT 
      FIRST(Price) as OpenPrice
FROM 
    MyWindow
;

INSERT INTO OutOpenCloseMinMax2
SELECT 

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

FROM 
    MyWindow