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
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1145-171K
Language
English (United States)

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            ?