Archives of the TeradataForum
Message Posted: Tue, 07 Sep 2004 @ 19:20:20 GMT
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:
|