|
|
Archives of the TeradataForum
Message Posted: Thu, 09 Sep 2004 @ 11:01:27 GMT
Subj: | | Re: SQL puzzle... |
|
From: | | Subramanian, Suresh |
Hope this helps
sel * from bla1 a
inner 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
)
union
sel * from bla1 a
left join
bla2 b
on a.bdf=b.bdf
and a.sai=b.sai
and a.ek_akt=b.ek_akt
and
0=b.genre
where a.genre not in ( sel a.genre from bla1 a
inner 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
)
)
union
sel * from bla1 a
left join
bla2 b
on a.bdf=b.bdf
and a.sai=b.sai
and a.ek_akt=b.ek_akt
and
0=b.genre
where a.genre is null
Cheers
Suresh
| |