Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 08 Jun 2006 @ 09:57:28 GMT


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


Subj:   Re: SQL to Normalize Columns to Rows
 
From:   Anomy Anom

<-- Anonymously Posted: Wednesday, June 07, 2006 19:54 -->

How about - set up a "types" table with 250 type_id's. Then you might be able to get away with the following set based solution:

     insert into newtable
     select customer_number,
            type_id,
            (case when type_id = 1 then col001
                  when type_id = 2 then col002
     ....
             end) as sales_amount
     from oldtable o
     cross join types t
     where sales_amount is not null;


     
  <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: 15 Jun 2023