PIVOT FUNCTION in Teradata 15.10

Database
Enthusiast

Re: PIVOT FUNCTION in Teradata 15.10

Hi ,

 

By when TDExpress 16.0 (Vmware) will be available .

 

Regards

Abhishek

Re: PIVOT FUNCTION in Teradata 15.10

PIVOT and UNPIVOT.

I dont see any examples in the documentation. I would love to use this funciton.

Teradata Employee

Re: PIVOT FUNCTION in Teradata 15.10

TD_UNPIVOT table operator is documented in SQL Reference: SQL Functions, Operators, Expressions, and Predicates manual.

There is no PIVOT in TD15.10

Re: PIVOT FUNCTION in Teradata 15.10

Teradata 16.2 SQL Guilde.pdf pg 66. 

Are these PDF published online and open to the public?

Teradata Employee

Re: PIVOT FUNCTION in Teradata 15.10

Enthusiast

Re: PIVOT FUNCTION in Teradata 15.10

HI ,

T1   --1 row 6 columns 

---

c_id1,c_id2,c_id3,c_id4,c_id5,c_id6

1,2,3,4,5,6

need results  -- 1 column 6 rows like below.

c_id

1

2

3

4

5

6

 

can i get help

 

Teradata Employee

Re: PIVOT FUNCTION in Teradata 15.10

Hi VratnamR,

 

You can try one of those solution.

UNION ALL

with T1 (c_id1, c_id2, c_id3, c_id4, c_id5, c_id6) as
(
select 1, 2, 3, 4, 5, 6
)
select c_id1 as c_id from T1 union all
select c_id2         from T1 union all
select c_id3         from T1 union all
select c_id4         from T1 union all
select c_id5         from T1 union all
select c_id6         from T1;

 

TD_UNPIVOT

with T1 (c_id1, c_id2, c_id3, c_id4, c_id5, c_id6) as
(
select 1, 2, 3, 4, 5, 6
)
select c_id
  from TD_UNPIVOT(ON (select c_id1, c_id2, c_id3, c_id4, c_id5, c_id6 from T1)
                  USING VALUE_COLUMNS('c_id')
                        UNPIVOT_COLUMN('upvt_col')
                        COLUMN_LIST('c_id1', 'c_id2', 'c_id3', 'c_id4', 'c_id5', 'c_id6')
                  ) as X;