TSCmp function
The TSCmp function compares two values.
Syntax
TSCmp(value1 smallfloat,
value2 smallfloat)
returns int;
TSCmp(value1 double precision,
value2 double precision)
returns int;
- value1
- The first value to be compared.
- value2
- The second value to be compared.
Description
Use the TSCmp function within the Apply function.
The TSCmp function takes either two SMALLFLOAT values or two DOUBLE PRECISION values; both values must be the same type. The TSCmp function can take parameters that are columns of a time series. Use the same parameter format that the Apply function accepts.
Returns
-1
- If the first argument is less than the second.
0
- If the first argument is equal to the second.
1
- If the first argument is greater than the second.
Example
The following example uses the TSCmp function to calculate the on-balance
volume, a continuous summation that adds the daily volume to the running total if the
stock or index advances and subtracts the volume if it
declines:
select Apply
('TSAddPrevious(TSCmp($final, TSPrevious($final)) * $vol)',
'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 = 'HCLTECH';