ApplyUnaryTsOp 函数将一元算术函数应用到时间系列。
ApplyUnaryTsOp(func_name lvarchar,
ts TimeSeries)
returns TimeSeries;
此函数以与一元算术函数类似的方式运算,已重载一元算术函数来对时间系列执行运算。请参阅一元算术函数部分中这些函数的描述以获取更多信息。例如,Logn(ts1) 与 ApplyUnaryTsOp(‘Logn', ts1) 等效。
与提供的时间系列具有相同类型的时间系列。
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;