GetNthElem 函数抽取时间系列中特定偏移量或位置上的条目。
GetNthElem(ts TimeSeries, N integer, flags integer default 0) returns row;
对于不规则的时间系列,GetNthElem 函数返回找到的第 N 个元素。对于规则的时间系列,第 N 个元素也是从时间系列开头的算起的第 N 个时间间隔。
与此函数等效的 API 为 ts_nth_elem()。
请求偏移量的行值,包括该时间点的所有时间系列数据和条目在时间系列日历中的时间戳记。该行的类型与时间系列子类型相同。
如果偏移量大于时间系列中最后一个元素的偏移量,那么将返回 NULL。
select GetNthElem(stock_data,GetNelems(stock_data)-1) from daily_stocks where stock_name = 'GBase';
select GetNthElem(stock_data,GetIndex(stock_data, '2011-01-04 00:00:00.00000')) from daily_stocks where stock_name = 'GBase';