Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 27 Apr 2006 @ 10:14:02 GMT


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


Subj:   Need Help Writing SQL
 
From:   Anomy Anom

<-- Anonymously Posted: Thursday, April 27, 2006 06:10 -->

I need to write an sql, which I will illustrate using the following example: (I grouped on col1 values for illustration only):

     TabA:

     col1   col2   col3

     123   222   1
     123   333   2
     123   444   1

     234   555   1
     234   666   1
     234   777   1

     345   888   2
     345   999   2
     345   111   2

     TabB:

     col1   col1   col3   col4

     Grp1   123   222   1   8
            123   333   2   8
            123   444   1   8

     Grp2   234   555   1   1
            234   666   1   1
            234   777   1   1

     Grp3   345   888   2   2
            345   999   2   2
            345   111   2   2

I want to populate TabB.col4 so that

If all col1's col2 have a col3 value of 1, then 1 (Grp 2 above)

If all col1's col2 have a col3 value of 2, then 2 (Grp3 above_

If a col1 has a mix of col2 with a mix of col3 values the set TabB.col4 to 8 (Grp 1 above)


Many thanks for any help that you may be able to give.



     
  <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