Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 28 Jul 2009 @ 19:49:34 GMT


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


Subj:   Re: Transpose or Pivot data
 
From:   Poston, Donna

Hi Fred, you can use case statements to denormalize the data.

     Select location
       ,unit_id
       ,sum (case when fault = 3 then 1 else 0 end) (title 'fault 3')
       ,sum (case when fault = 35 then 1 else 0 end) (title 'fault 35')
       ,sum (case case when fault = 155 then 1 else 0 end) (title 'fault 155')
       ,sum (case when fault = 156 then 1 else 0 end) (title 'fault 156')

     From database
     Where location = 4443
       And unit_ID = 3124
       And fault=3 OR fault=35 OR fault=155 or fault=156
     Group by location, unit_Id
     Order by location, unit_ID


     
  <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