TSAddPrevious 函数

TSAddPrevious 函数对调用函数所使用的所有值求和,并在每次调用时返回当前总和。总和中不包括当前自变量。

语法

TSAddPrevious(current_value smallfloat) 
returns smallfloat;

TSAddPrevious(current_value double precision) 
returns double precision;
current_value
当前值。

描述

AggregateByApply 函数内使用 TSAddPrevious 函数。TSAddPrevious 函数可以采用作为时间系列的列的参数。使用 AggregateByApply 函数接受的相同参数格式。

返回结果

此函数返回的所有先前值的总和。

示例

以下示例使用 TSAddPrevious 函数来计算进出市场或股权的平均美元总和:
select Apply('TSAddPrevious($vol * (($final - $low) - ($high - $final) / (.0001
+ $high - $low)) * (($high + $low + $final) / 3))',
      '2011-01-03 00:00:00.00000'::datetime year to fraction(5),
      '2011-01-08 00:00:00.00000'::datetime year to fraction(5),
      stock_data)::TimeSeries(one_real)
from daily_stocks
where stock_name = 'GBase';