GetPreviousValid 函数

GetPreviousValid 函数返回给定时间戳记之前的最后一个元素。

语法

GetPreviousValid(ts     TimeSeries, 
                tstamp datetime year to fraction(5),
                flags  integer default 0) 
returns row;
ts
源时间系列。
tstamp
关注的时间戳记。
flags
flags 参数值中描述了 flags 参数的有效值。缺省值为 0

描述

等效的 API 函数为 ts_previous_valid()

返回结果

包含给定时间戳记之前的最后一个元素的行。该行的类型与时间系列子类型相同。

如果时间戳记早于或等于时间系列原点,那么将返回 NULL

示例

以下查询获取规则的时间系列中时间戳记 2011-01-05 之前的第一个元素:
select GetPreviousValid(stock_data, 
   '2011-01-05 00:00:00.00000')
   from daily_stocks
   where stock_name = 'GBase';
以下查询获取不规则的时间系列中时间戳记 2011-01-05 之前的第一个元素:
select GetPreviousValid(activity_data, 
   '2011-01-05 00:00:00.00000')
   from activity_stocks
   where stock_id = 600;