Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Transpose columns to rows - response (1) by dnoeth

$
0
0

Hi Chandrashekar,
you should avoid recursion for stuff like that, it will result in huge spool usage.
There are two common solutions for:

select cust, act1 as accnt from tab where act1 is not null
union all
select cust, act2 as accnt from tab where act2 is not null
union all
select cust, act3 as accnt from tab where act3 is not null
union all
...

or a cross join to a table with integers like:

select cust, 
  case x 
    when 1 then act1 
    when 2 then act2 
    when 3 then act3
    ... 
  end as accnt 
from tab cross join 
  (select day_of_calendar as x from sys_calendar.calendar
   where x between 1 and 15) as dt

Dieter
 


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>