I do have the following issue: Let’s say you have a table that looks like this:
x
"ExampleTable"NotPrimID Number0 130 130 141 141 142 132 13Question: I want to have an query which will deliver all the NotPrimID‘s which do have the Number as 13, however if the Number of a NotPrimID is also 14 etc. it should be automatically excluded from the list.
Advertisement
Answer
You could use exists logic here:
SELECT DISTINCT NotPrimIDFROM ExampleTable t1WHERE Number = 13 AND NOT EXISTS (SELECT 1 FROM ExampleTable t2 WHERE t2.NotPrimID = t1.NotPrimID AND t2.Number = 14);