all groups > sql server mseq > january 2007 >
You're in the

sql server mseq

group:

Group by Not in the Group


Group by Not in the Group Phil
1/25/2007 6:11:02 AM
sql server mseq:
Hi,

I am trying to work out a way of finding out if certain values do not appear
in the group by e.g.

ID Ref
1 1
1 2
2 3
2 2
3 1
3 1

I would only want to return ID 1 and 3 as these are the only ID's that dont
have a Ref of 3, if that makes any sense, does anyone know how this is done.

Thanks

RE: Group by Not in the Group JayAchTee
2/22/2007 6:30:08 PM
Try this:

SELECT DISTINCT [ID] FROM [Test] WHERE [ID] NOT IN (SELECT DISTINCT [ID]
FROM [Test] WHERE [Ref] = 3)

--
Regards,

JayAchTee


[quoted text, click to view]
AddThis Social Bookmark Button