Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 07 Sep 2004 @ 19:20:20 GMT


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


Subj:   Re: SQL puzzle...
 
From:   Anomy Anom

<-- Anonymously Posted: Tuesday, September 07, 2004 15:11 -->

     left join bla2 b
     on (a.bdf=b.bdf
     and a.sai=b.sai
     and a.ek_akt=b.ek_akt
     and a.genre=b.genre
     )
     or (a.bdf=b.bdf
     and a.sai=b.sai
     and a.ek_akt=b.ek_akt
     and 0=b.genre)
     ;   is equivalent to saying a.bdf = b.bdf and a.sai = b.sai and a.ek_akt
     = b.ek_akt and (b.genre = a.genre or b.genre = 0)

The OR brings you all the rows that is true for the condition!.

To get the result you wanted you should say,

     select from a join b (on all 4 columns), a join b on 3 columns +
     genre=0 where there is no exact match...

--Hope this helps:



     
  <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