  |  
  |  
 
Archives of the TeradataForum 
 
 
Message Posted: Thu, 08 Jun 2006 @ 09:57:28 GMT 
 
  
 
 
 
 
  
|  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;
 
 
 
 
   
 
 |   |