我有下表:
| 名稱 | 會議 |
|---|---|
| 第一的 | 101 |
| 第一的 | 301 |
| 第一的 | 701 |
| 第二 | 501 |
| 第二 | 601 |
| 第二 | 701 |
我想使用 Postgres 獲取所有沒有 CONF = 101、201 或 301 的名稱。在這種情況下,只有Second。我試過IN,NOT IN和ANY。但永遠得不到預期的結果。
uj5u.com熱心網友回復:
這是一種解決方案:
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))
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/384212.html
標籤:PostgreSQL的
