我在select的where子句中有一个'not in‘,我试图将其转换为'not exists’
我尝试切换最小值,但没有填充任何内容(它确实执行了
where [a] not in (
select
[a]
from table
group by [a]
having count(*) > 1) -- Ignores Records with duplicate data发布于 2019-05-08 23:23:01
您可以按如下方式执行此操作:
where not exists (select 1
from table t2
where ?.a = t2.a
group by t2.a
having count(*) > 1
)不过,这通常是在查询的表中查找对相同值的另一个引用。如果是这样,请避免使用聚合:
where not exists (select 1
from table t2
where ?.a = t2.a and ?.id <> t2.id
)https://stackoverflow.com/questions/56044050
复制相似问题