Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 24 Jun 2005 @ 22:13:04 GMT


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


Subj:   Re: SQL to flattening a table
 
From:   Prescott, Kyle R

Single pass with group by to pivot rows....

     Select  a.cust,
             Sum(case when a.acct = 100 then a.bal else 0 end) as bal_100,
             Sum(case when a.acct = 200 then a.bal else 0 end) as bal_200,

             Sum(case when a.acct = 300 then a.bal else 0 end) as bal_300
     From tbl1 a
     Group by 1

Kyle Prescott
UnumProvident, Data Strategies



     
  <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