November 3rd, 2015, 03:15 AM
Join Date: Nov 2015
Time spent in forums: 20 m 57 sec
Reputation Power: 0
Originally Posted by rourlogan
Hello all! My first post here, looking for a little bit of help
I only want the query to return rows that ONLY have ABC, DEF, GHI, but if even one row has XXX or ZZZ then it doesnt return that ID at all.
Here's what the table looks like..
UniqID | Status
1 | ABC
1 | DEF
1 | GHI
1 | XXX
1 | ZZZ
2 | ABC
My code looks like this
WHERE STATUS = 'ABC' Or Status = 'DEF' Or Status = 'GHI
The problem here is that it returns the rows that DO meet this condition I just don't know how to tell it to ignore them if they have any of the XXX or ZZZ in the rows.
Any help is appreciated thanks!
Try this one!!!
Select UniqID, STATUS from #table5 where STATUS in ('ABC','DEF','GHI');