1 回答

TA貢獻1946條經驗 獲得超3個贊
您可以枚舉派生表中的值,然后使用not exists和聚合:
select min(v.num) num
from (
select 300420 num
union all select 300421
union all select 300422
union all select 300423
) v
where not exists (select 1 from itensnfs i where i.Num_Nota = v.num)
根據您的數據庫,有更簡潔的替代方案union all 來生成派生表。
一些數據庫支持行構造函數values():
select min(v.num) num
from (values (300420), (300421), (300422), (300423)) v(num)
where not exists (select 1 from itensnfs i where i.Num_Nota = v.num)
MySQL 是一個值得注意的例外 - 但最近的版本支持values row():
select min(v.num) num
from (values row (300420), row (300421), row (300422), row (300423)) v(num)
where not exists (select 1 from itensnfs i where i.Num_Nota = v.num)
- 1 回答
- 0 關注
- 150 瀏覽
添加回答
舉報