我试图在select的where子句中将其变成“不存在”
我尝试切换最低限度,但没有填充任何内容(确实执行了
where [a] not in (
select
[a]
from table
group by [a]
having count(*) > 1) -- Ignores Records with duplicate data
答案 0 :(得分:1)
您可以按照以下步骤进行操作:
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
)