Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I would like to do something like this:SELECT DISTINCT t.IDFROM table tWHERE t.code IS NEVER IN 'ABC'So if the person with ID #000123 has 50 records each with a different code, I only want their ID to appear IF they DONT have a record with code ABC. Not sure how???
bitsmed
Aged Yak Warrior
545 Posts
Posted - 2013-10-01 : 11:46:04
Try this:
select id from table group by id having sum(case when code='ABC' then 1 else 0 end)=0