UNPIVOT Function Examples | VantageCloud Lake - UNPIVOT Function Examples - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

The examples in this section use the following denormalized pivoted table, star1p, which is defined as:

CREATE TABLE star1p(country VARCHAR(20),state VARCHAR(20),Q101Sales INTEGER,Q201Sales INTEGER,Q301Sales INTEGER,Q101Cogs INTEGER,Q201Cogs INTEGER,Q301Cogs INTEGER);

SELECT * FROM star1p;

The star1p table contains:

country  state  Q101Sales  Q201Sales  Q301Sales  Q101Cogs  Q201Cogs  Q301Cogs
-------  -----  ---------  ---------  ---------  --------  --------  --------
Canada    ON        ?         10          ?         ?         0         ?
Canada    BC        ?          ?         10         ?         ?         0
USA       NY       45          ?          ?        25         ?         ?
USA       CA       30         50          ?        15        20         ?