查询数据表,去除符合某些条件的记录,没有自动增长列(not exists)

时间:2023-10-22 12:28:32

select distinct ccode,isnull(cexch_name,''),N'',N'',N'2014.03',0,1,1,1,12 from RP_bankrecp

where not exists(

select distinct r.ccode,isnull(r.cexch_name,'')

from RP_bankrecp  r inner join gl_bankalert g on r.ccode=g.ccode and isnull(r.cexch_name,'')= isnull(g.cexch_name,'')

where iyear=2014

)

这样是错误的,not exists 只是返回是否有结果集,相当于一个true or false的值