17.10 - Example: Table Source Using the WITH Clause - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/djk1612415574830.ditamap
dita:ditavalPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/wrg1590696035526.ditaval
dita:id
kby1472250656485

The following is an example of a table using the WITH clause as a source to the pivot query.

SELECT *
FROM (with temp
as (select * from s1) select * from temp)dt PIVOT (SUM(sales) FOR mon IN ('Jan','Feb', 'Mar'))tmp;

 *** Query completed. 3 rows found. 4 columns returned.
 *** Total elapsed time was 1 second.
         yr          Jan          Feb          Mar
      -----        ------       ------      -------
       2001          100          110          120
       2002          150          200          250
       2003          300          310            ?