I have the following table:
name | Conf |
---|---|
First | 101 |
First | 301 |
First | 701 |
Second | 501 |
Second | 601 |
Second | 701 |
I want to get all names that do not have CONF = 101, 201 or 301 with Postgres. In this case, only Second. I tried with IN, NOT IN and ANY. But never get the expected result.
CodePudding user response:
Here is one solution:
select distinct src.name
from the_table as src
where not exists (
select 1
from the_table as other
where other.name = src.name
and other.conf in (101,201,301))