TD_DIFF Function Examples | Teradata Vantage - TD_DIFF Examples - Teradata Vantage

Database Unbounded Array Framework Time Series Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
ncd1634149624743.ditamap
dita:ditavalPath
ruu1634160136230.ditaval
dita:id
ncd1634149624743
lifecycle
latest

Example: TD_DIFF Call with REAL Input Time Series

EXECUTE FUNCTION INTO VOLATILE ART (DIFF_RESULTS)
  TD_DIFF (
    SERIES_SPEC (
      TABLE_NAME (OCEAN_BUOYS),
      ROW_AXIS (TIMECODE (TD_TIMECODE)),
      SERIES_ID (Ocean_Name, BuoyID),
      PAYLOAD (FIELDS (SALINITY), CONTENT (REAL))),
      FUNC_PARAMS (
        LAG (1),
        DIFFERENCES (2),
        SEASONAL_MULTIPLIER (0)
      )
    )
  );

TD_DIFF Result for REAL Content

SELECT * FROM DIFF_RESULTS;
BuoyID ROW_I OUT_
----------- ----------- ----------------------
33 0 -5.90000000000000E 001
33 1 8.60000000000000E 001
33 2 -1.26000000000000E 002
33 3 1.01000000000000E 002
33 4 -8.20000000000000E 001
33 5 6.80000000000000E 001
33 6 -6.10000000000000E 001
33 7 5.60000000000000E 001
33 8 3.40000000000000E 001
33 9 -6.50000000000000E 001
33 10 2.10000000000000E 001
33 11 -6.20000000000000E 001
33 12 1.10000000000000E 002
33 13 -7.30000000000000E 001

Example: TD_DIFF Call with MULTIVAR_REAL Input Time Series

EXECUTE FUNCTION INTO VOLATILE ART(DIFF_RESULTS2)
   TD_DIFF(SERIES_SPEC(TABLE_NAME(OceanBuoy2), ROW_AXIS(SEQUENCE(N_SeqNo)),
      SERIES_ID(BuoyID), PAYLOAD(FIELDS(Magnitude1, Magnitude2),
      CONTENT(MULTIVAR_REAL))),
   FUNC_PARAMS( LAG(1), DIFFERENCES(2), SEASONAL_MULTIPLIER(0) )
);

TD_DIFF Result for MULTIVAR_REAL Content Using SELECT Statement

SELECT * FROM DIFF_RESULTS;
BuoyID ROW_I OUT_MAGNITUDE1 OUT_MAGNITUDE2
----------- ----------- ---------------------- ----------------------
33 0 -5.90000000000000E 001 -5.90000000000000E 000
33 1 8.60000000000000E 001 8.60000000000000E 000
33 2 -1.26000000000000E 002 -1.26000000000000E 001
33 3 1.01000000000000E 002 1.01000000000000E 001
33 4 -8.20000000000000E 001 -8.20000000000000E 000
33 5 6.80000000000000E 001 6.80000000000000E 000
33 6 -6.10000000000000E 001 -6.10000000000000E 000
33 7 5.60000000000000E 001 5.60000000000000E 000
33 8 3.40000000000000E 001 3.40000000000000E 000
33 9 -6.50000000000000E 001 -6.50000000000000E 000
33 10 2.10000000000000E 001 2.10000000000000E 000
33 11 -6.20000000000000E 001 -6.20000000000000E 000
33 12 1.10000000000000E 002 1.10000000000000E 001
33 13 -7.30000000000000E 001 -7.30000000000000E 000

TD_DIFF Result for MULTIVAR_REAL Content Using TD_EXTRACT_RESULTS Statement

EXECUTE FUNCTION
TD_EXTRACT_RESULTS( ART_SPEC(TABLE_NAME(DIFF_RESULTS2), LAYER(ARTPRIMARY) ) );
BuoyID ROW_I OUT_MAGNITUDE1 OUT_MAGNITUDE2
----------- ----------- ---------------------- ----------------------
33 0 -5.90000000000000E 001 -5.90000000000000E 000
33 1 8.60000000000000E 001 8.60000000000000E 000
33 2 -1.26000000000000E 002 -1.26000000000000E 001
33 3 1.01000000000000E 002 1.01000000000000E 001
33 4 -8.20000000000000E 001 -8.20000000000000E 000
33 5 6.80000000000000E 001 6.80000000000000E 000
33 6 -6.10000000000000E 001 -6.10000000000000E 000
33 7 5.60000000000000E 001 5.60000000000000E 000
33 8 3.40000000000000E 001 3.40000000000000E 000
33 9 -6.50000000000000E 001 -6.50000000000000E 000
33 10 2.10000000000000E 001 2.10000000000000E 000
33 11 -6.20000000000000E 001 -6.20000000000000E 000
33 12 1.10000000000000E 002 1.10000000000000E 001
33 13 -7.30000000000000E 001 -7.30000000000000E 000