【发布时间】:2021-02-25 09:49:51
【问题描述】:
我正在寻找那些没有支付任何费用的 ID。
有一些重复的 ID,其中一些记录的 FeePaid 不为空,一些记录的 FeePaid 为空。
为什么这两个查询返回不同的输出?
select distinct ID
from MyTable
where FeePaid is null
and ID not in (select distinct ID from MyTable
where FeePaid is not null)
和
select distinct ID
from myTable
where FeePaid is null
except
select distinct ID
from MyTable
where FeePaid is not null
【问题讨论】:
标签: sql sql-server except