PivotColumn - Analytics Database

Database Analytic Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
gjn1627595495337.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
jmh1512506877710
Product Category
Teradata Vantageā„¢

The following example assumes the titanic dataset table exists.

Calling TD_Pivoting with PivotColumn

SELECT * FROM TD_Pivoting (
  ON titanic_dataset_unpivoted AS InputTable PARTITION BY passenger
  USING
  PartitionColumns ('passenger')
  TargetColumns ('AttributeValue')
  Accumulate ('survived')
  PivotColumn('AttributeName')
  PivotKeys('pclass','sex')
) AS dt Order By passenger;

TD_Pivoting Output

passenger AttributeValue_pclass AttributeValue_gender survived
--------- --------------------- --------------------- --------
2         1                     female                1
4         1                     female                1
7         1                     male                  0
10        2                     female                1
16        2                     female                1
21        2                     male                  0
40        3                     female                1
61        3                     male                  0
1000      3                     ?                     1