16.20 - Example: Using an IN List with Multiple Column Lists and Unspecified Aliases - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2020-03-25
dita:mapPath
xzf1512079057909.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval
dita:id
kby1472250656485

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