PIVOT Function Syntax | Teradata Vantage - PIVOT Function Syntax - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢
PIVOT ( pivot_spec )
  [ WITH with_spec [,...] ]
  [AS] derived_table_name [ ( cname [,...] ) ]

Syntax Elements

pivot_spec
aggr_fn_spec [,...] FOR for_spec
with_spec
aggr_fn ( { cname [,...] | * } ) [AS] aggr_alias
derived_table_name
The table name specified for the resultant pivoted table.
cname
A column name.
aggr_fn_spec
aggr_fn ( cname ) [ [AS] pvt_aggr_alias ]
for_spec
{ cname IN ( expr_spec_1 [,...] ) |
  ( cname [,...] ) IN ( expr_spec_2 [,...] ) |
  cname IN ( subquery )
}
aggr_fn
An aggregate function that supports a single argument.
*
Option to include all the Pivot columns without specifying columns explicitly.
aggr_alias
Name of the aggregate result column.
pvt_aggr_alias
An alias name specified for the Aggregate function.
expr_spec_1
expr [ [AS] expr_alias_name ]
expr_spec_2
( expr [,...] ) [ [AS] expr_alias_name ]
expr
An expression or a column value.
expr_alias_name
An alias name specified for the values/expressions specified in the IN list.