ApplyUnaryTsOp 函数

ApplyUnaryTsOp 函数将一元算术函数应用到时间系列。

语法

ApplyUnaryTsOp(func_name lvarchar, 
               ts        TimeSeries) 
returns TimeSeries;
func_name
一元算术函数的名称。
ts
要对其执行操作的时间系列。

描述

此函数以与一元算术函数类似的方式运算,已重载一元算术函数来对时间系列执行运算。请参阅一元算术函数部分中这些函数的描述以获取更多信息。例如,Logn(ts1)ApplyUnaryTsOp(‘Logn', ts1) 等效。

返回结果

与提供的时间系列具有相同类型的时间系列。

示例

以下示例结合使用 ApplyUnaryTSOpLogn 函数:
create row type simple_series( stock_id int, data TimeSeries(one_real));
create table daily_high of type simple_series;
insert into daily_high
   select stock_id,
      Apply( '$0.high',
         NULL::datetime year to fraction(5),
         NULL::datetime year to fraction(5),
         stock_data)::TimeSeries(one_real)
      from daily_stocks;
create table daily_low of type simple_series;
insert into daily_low
   select stock_id,
      Apply( '$0.low',
         NULL::datetime year to fraction(5),
         NULL::datetime year to fraction(5),
         stock_data)::TimeSeries(one_real)
      from daily_stocks;
create table daily_avg of type simple_series;
insert into daily_avg
   select l.stock_id, ApplyBinaryTSOp("plus", l.data, h.data)/2
      from daily_low l, daily_high h
      where l.stock_id = h.stock_id;
create table log_high of type simple_series;
insert into log_high
   select stock_id, ApplyUnaryTsOp( "logn", 
   data) from daily_avg;