Remove results if id has specific value with multiple values
-
The title doesn't help and hopefully I can explain this right. I need to exclude the PartNum from a query if it is in the KARDEX bin. These parts have multiple bins. If a part has the Kardex bin I want to exclude the part. Here's sample data.
So I want to exclude 100217 and 101104-003 but keep the others.
-
Since you didn't include sufficient details in your question, I can only give you a basic idea how that should work:
select * from yourtable x where not exists ( select 1 from yourtable y where x.partnum = y.partnum -- same part number and y.binnum = 'KARDEX' -- but in the KARDEX bin )