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 关注
- 84 浏览
添加回答
举报