TS_FIRST_VALUE
Processes the data that belongs to each time slice. A time series aggregate (TSA) function, TS_FIRST_VALUE
returns the value at the start of the time slice, where an interpolation scheme is applied if the timeslice is missing, in which case the value is determined by the values corresponding to the previous (and next) timeslices based on the interpolation scheme of const (linear).
TS_FIRST_VALUE
returns one output row per time slice, or one output row per partition per time slice if partition expressions are specified
Behavior Type
Syntax
TS_FIRST_VALUE ( expression [ IGNORE NULLS ] [, { 'CONST' | 'LINEAR' } ] )
Parameters
expression |
An |
IGNORE NULLS
|
The |
'CONST' | 'LINEAR'
|
Specifies the interpolation value as constant or linear:
|
Requirements
You must use an ORDER BY
clause with a TIMESTAMP
column.
Multiple Time Series Aggregate Functions
The same query can call multiple time series aggregate functions. They share the same gap-filling policy as defined by the TIMESERIES Clause; however, each time series aggregate function can specify its own interpolation policy. For example:
=> SELECT slice_time, symbol, TS_FIRST_VALUE(bid, 'const
') fv_c, TS_FIRST_VALUE(bid, 'linear
') fv_l, TS_LAST_VALUE(bid, 'const
') lv_c FROM TickStore TIMESERIESslice_time AS '3 seconds'
OVER(PARTITION BY symbol ORDER BY ts);
Examples
See Gap Filling and Interpolation in Analyzing Data.