Posted by figital on 04/12/06 02:25
Tom and David,
Thank you very much for your help!
I had to add a check because of the left join but otherwise, awesome!
SELECT a.B
FROM @a a
left join @a b on b.C = a.C
and b.D = a.D
and b.B = @i
where a.B <> @i and NOT (B.C IS NULL OR B.D IS NULL)
group by
a.B
having
count (distinct a.D) = (select count (distinct D) from @a where B =
@i)
Navigation:
[Reply to this message]
|