Differences a seasonal or nonseasonal time series.
TS_DIFFERENCE (timeseries_expression, period1 [, period2 [, ...period 10] ]) OVER (window-spec)
For each element in the time series, TS_DIFFERENCE returns the corresponding calculated differenced value for the time series; it calls the function imsls_d_difference in the IMSL libraries.
The arguments of TS_DIFFERENCE map to the IMSL library function imsls_d_difference as follows:
params = imsls_d_difference(n_objs, z[], n_differences, periods [], 0);
For detailed information on how the function imsls_d_difference performs time series calculations, see IMSL C Numerical Library User’s Guide Volume 2 of 2: C Stat Library.
This example shows a SQL statement containing the TS_DIFFERENCE function and the data values returned by the function. This example uses the example input data table (called DATASET) as its input data.
SELECT TS_DIFFERENCE(data,1) OVER (ORDER BY ROWNUM rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS res FROM DATASET
Sybase IQ returns 50 rows:
res |
---|
NULL |
0.170336 |
0.191027 |
1.29692 |
0.801743 |
-0.038988 |
-0.09424 |
1.61886 |
-1.12477 |
1.02925 |
-1.20614 |
-0.814478 |
-0.157049 |
-1.18213 |
0.027546 |
1.45734 |
-0.990302 |
-0.833325 |
-0.637229 |
-0.08655 |
-0.12594 |
-0.122914 |
-1.39596 |
0.919785 |
-0.449474 |
0.037273 |
-0.954345 |
-0.562983 |
1.98379 |
0.88304 |
-0.345265 |
0.934656 |
0.069088 |
-0.249428 |
0.795766 |
-1.8145 |
1.27016 |
1.39266 |
-0.141794 |
0.934752 |
0.982506 |
0.330772 |
-1.34311 |
1.23124 |
0.209869 |
0.791146 |
-0.259155 |
0.15124 |
-0.963484 |
0.383186 |