TSRunningSum 函数计算 SMALLFLOAT 或 DOUBLE PRECISION 值的运行总和。
TSRunningSum(value smallfloat, num_values integer) returns smallfloat; TSRunningSum(value double precision, num_values integer) returns double precision;
运行总和是最后 k 个值的总和,其中 k 由用户提供。如果值是 NULL,会使用上一个值。
此函数是运行固定数量的元素,而非运行固定时间长度;因此,它可能不适用于非常规时间系列。
只有在 Apply 函数内使用时此函数才有用。
最后 k 个值的 SMALLFLOAT 或 DOUBLE PRECISION 运行总和。
create function VAP(a float, b float,c float,d float, e int) returns int; return cast(100 * TSRunningSum(d * ((c - b) - (a - c))/ (.0001 + a - b), e)/(.0001 + TSRunningSum(d,e)) as int); end function;