TD_SEASONALNORMALIZE Function Examples | Teradata Vantage - TD_SEASONALNORMALIZE 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

Example: TD_SEASONALNORMALIZE Call to Normalize River Velocity

EXECUTE FUNCTION INTO VOLATILE ART(NORM_SERIES)
TD_SEASONALNORMALIZE(
   SERIES_SPEC(TABLE_NAME(RiverData),ROW_AXIS(TIMECODE(timevalue)), SERIES_ID(StationID),
      PAYLOAD(FIELDS(FlowVelocity), CONTENT(REAL)),INTERVAL(CAL_MONTHS(1)) ),
   FUNC_PARAMS(SEASON_CYCLE(CYCLES("CAL_MONTHS"), DURATION(1))), 
      OUTPUT_FMT( INDEX_STYLE(NUMERICAL_SEQUENCE) )
);

TD_SEASONALNORMALIZE Output for Normalize River Velocity

SELECT TOP 10 * FROM NORM_SERIES ORDER BY ROW_I;
StationID ROW_I FlowVelocity
----------- -------------------- ----------------------
101201 0 -4.70735178251868E-001
101201 1 2.17754337960899E 000
101201 2 3.97661379474619E 000
101201 3 -3.29385753287450E-002
101201 4 -4.79530199292734E-001
101201 5 -7.56084749799974E-001
101201 6 -8.89964514533161E-001
101201 7 -9.55438560059611E-001
101201 8 -9.81823623182210E-001
101201 9 -9.90618644223076E-001

TD_SEASONALNORMALIZE Input Table StoreSales

ROW_ID TD_TIMECODE StoreID Sales
1 2022-01-16 16:05:00.000000 43300 120.00000
2 2022-01-17 16:05:00.000000 43300 105.00000
3 2022-01-18 16:05:00.000000 43300 115.00000
4 2022-02-16 16:05:00.000000 43300 140.00000
5 2022-02-17 16:05:00.000000 43300 145.00000
... ... ... ...

Example: TD_SEASONALNORMALIZE Call for Store Sales

EXECUTE FUNCTION INTO VOLATILE ART(NORM_STORE_SALES)
TD_SEASONALNORMALIZE(
   SERIES_SPEC(TABLE_NAME(StoreSales), ROW_AXIS(TIMECODE(TD_TIMECODE)), 
      SERIES_ID(StoreID), PAYLOAD( FIELDS(Sales), CONTENT(REAL)),
      INTERVAL(CAL_MONTHS(1))),
   FUNC_PARAMS(SEASON_CYCLE(CYCLES("CAL_YEARS"), DURATION(1)), SEASON_INFO(3) ),
      OUTPUT_FMT( INDEX_STYLE(FLOW_THROUGH) ) 
);

TD_SEASONALNORMALIZE Output for Store Sales

SELECT TOP 10 * FROM NORM_STORE_SALES ORDER BY ROW_I;
StoreID ROW_I SEASON_NO CYCLE_NO Sales
----------- -------------------------- -------------------- -------------------- ----------------------
43300 2022-01-16 16:05:00.000000 0 1 1.06904496764970E 000
43300 2022-01-17 16:05:00.000000 0 1 -1.33630620956212E 000
43300 2022-01-18 16:05:00.000000 0 1 2.67261241912425E-001
43300 2022-02-16 16:05:00.000000 1 1 -9.80580675690921E-001
43300 2022-02-17 16:05:00.000000 1 1 -3.92232270276369E-001
43300 2022-02-18 16:05:00.000000 1 1 1.37281294596729E 000
43300 2022-03-16 16:05:00.000000 2 1 1.06904496764970E 000
43300 2022-03-17 16:05:00.000000 2 1 -1.33630620956212E 000
43300 2022-03-18 16:05:00.000000 2 1 2.67261241912425E-001
43300 2022-04-16 16:05:00.000000 3 1 -9.80580675690921E-001

Example: TD_SEASONALNORMALIZE Call for Secondary Result Set

EXECUTE FUNCTION INTO VOLATILE ART(NORM_METADATA)
TD_EXTRACT_RESULTS( 
   ART_SPEC(TABLE_NAME(NORM_STORE_SALES), LAYER(ARTMETADATA) ) 
);

TD_SEASONALNORMALIZE Output for Secondary Result Set

SELECT * FROM NORM_METADATA;
StoreID ROW_I MEAN_Sales SD_Sales
----------- -------------------- ---------------------- ----------------------
43300 0 1.13333333333333E 002 6.23609564462324E 000
43300 1 1.48333333333333E 002 8.49836585598797E 000
43300 2 1.13333333333333E 002 6.23609564462324E 000
43300 3 1.48333333333333E 002 8.49836585598797E 000
43300 4 1.13333333333333E 002 6.23609564462324E 000
43300 5 1.48333333333333E 002 8.49836585598797E 000
43300 6 1.13333333333333E 002 6.23609564462324E 000
43300 7 1.48333333333333E 002 8.49836585598797E 000
43300 8 1.13333333333333E 002 6.23609564462324E 000
43300 9 1.48333333333333E 002 8.49836585598797E 000
43300 10 1.13333333333333E 002 6.23609564462324E 000
43300 11 1.48333333333333E 002 8.49836585598797E 000