|
Posted by Tom Moreau on 04/12/06 02:38
Oh, OK. The input data didn't have nulls, so I didn't go there. Glad you
now have a solution. :-)
--
Tom
----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
..
"figital" <mharen@gmail.com> wrote in message
news:1144797933.088430.155480@g10g2000cwb.googlegroups.com...
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]
|