Example: Using an IN List with Multiple Column Lists and Unspecified Aliases - 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

In this example, the aliases that the IN list uses were not specified. Instead, the values of the yr_qtr column were built by adding the column names with an underscore symbol.

SELECT *
FROM star1p UNPIVOT ((sales, cogs)  FOR  yr_qtr IN
((Q101Sales, Q101Cogs),(Q201Sales, Q201Cogs), (Q301Sales, Q301Cogs)) Tmp;
country    state        yr_qtr                        sales         cogs
-------  -------- -----------------------            --------     --------
Canada     ON        Q201Sales_Q201Cogs                 10            0
Canada     ON        Q301Sales_Q301Cogs                 10            0
USA        NY        Q101Sales_Q101Cogs                 45           25
USA        CA        Q101Sales_Q101Cogs                 30           15
USA        CA        Q201Sales_Q201Cogs                 50           20