TD_UNNORMALIZE Function Example | Teradata Vantage - TD_UNNORMALIZE Example - 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

TD_UNNORMALIZE Input Tables

Input Table NORM_STORE_SALES
STORE_ID ROW_I SEASON_NO CYCLE_NO Sales
43300 2021-01-16 16:05:00 1 1 1.0690449676496983
43300 2021-01-17 16:05:00 1 1 -1.336306209562121
  2021-01-18 16:05:00 1 1 0.2672612419124251
43300 2021-02-16 16:05:00 2 1 -0.9805806756909214
43300 2021-02-17 16:05:00 2 1 -0.39223227027636925
... ... ... ... ...
Input Table NORM_METADATA
StoreID ROW_I MEAN_Sales SD_Sales
43300 1 113.33333333333333 6.236095644623236
43300 2 148.33333333333334 8.498365855987974
43300 3 113.33333333333333 6.236095644623236
43300 4 148.33333333333334 8.498365855987974
43300 5 113.33333333333333 6.236095644623236
... ... ... ...

TD_UNNORMALIZE Call

EXECUTE FUNCTION INTO VOLATILE ART(UNNORM_RES)
TD_UNNORMALIZE(
   SERIES_SPEC(TABLE_NAME(normalizedSales), SERIES_ID( StoreID ), 
      ROW_AXIS( TIMECODE( ROW_I ) ),
      PAYLOAD(FIELDS(Sales), CONTENT(REAL)),INTERVAL(CAL_MONTHS(1))),
      SERIES_SPEC(TABLE_NAME(metaTable), SERIES_ID(StoreID), ROW_AXIS(  
         SEQUENCE(ROW_I)), PAYLOAD(FIELDS(MEAN_Sales,SD_Sales),
         CONTENT(MULTIVAR_REAL))),
   INPUT_FMT(INPUT_MODE(MATCH)),
   OUTPUT_FMT(INDEX_STYLE(FLOW_THROUGH)) 
);

TD_UNNORMALIZE Output

Display results with this function call:
SELECT TOP 18 * FROM UNNORM_RES;
StoreID     ROW_I                    Sales
----------- -------- ----------------------
43300 2021-01-16 16:05:00 120.0
43300 2021-01-17 16:05:00 105.0
43300 2021-01-18 16:05:00 115.0
43300 2021-02-16 16:05:00 140.0
43300 2021-02-17 16:05:00 145.0
...