Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Fri, 10 Jan 2003 @ 08:53:58 GMT

  <Prev Next>   <<First <Prev Next> Last>>  

Subj:   Re: Please help
From:   Dieter Nöth

Hi Glenn,

instead of creating a table and doing lots of outer joins, you can simply use a derived table and a group by. This is much more efficient and easier to write:

   ,max(case when seq = 1 then dt.c2 end) as "1"
   ,max(case when seq = 2 then dt.c2 end) as "2"
   ,max(case when seq = 3 then dt.c2 end) as "3"
   ,max(case when seq = 4 then dt.c2 end) as "4"
   ,max(case when seq = 5 then dt.c2 end) as "5"
left join
      ,sum(1) over (partition by c1 order by c2
                    rows unbounded preceding) as seq
    from b
   ) dt
on a.c1 = dt.c1

group by
order by a.c1

It's still just solving a part of Sreya's problem, but to do all that dynamically you'll have to use a SP ;-)


  <Prev Next>   <<First <Prev Next> Last>>  
  Top Home Privacy Feedback  
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016