需求:查询数据表TB_ZH_MONTH_BACK里本月有帐户号而上月无对应帐户号的数据select NY||ZHH from TB_ZH_MONTH_BACKUP where NY = '当月' and not Exists (select * from TB_ZH_MONTH_BACKUP where NY = '前月')
select A.NY||A.ZHH from TB_ZH_MONTH_BACKUP A where A.NY = '当月' and not Exists ( select * from TB_ZH_MONTH_BACKUP B where B.NY = '前月' AND A.ZHH=B.ZHH );
select a.NY||ZHH from TB_ZH_MONTH_BACKUP a where a.NY = '当月' and not Exists (select 1 from TB_ZH_MONTH_BACKUP b where b.NY = '前月' and a.帐户号 = b.帐户号)
select t1.NY||t1.ZHH from TB_ZH_MONTH_BACKUP t1, TB_ZH_MONTH_BACKUP t2 where t1.NY = '当月' and t2.NY = '前月' and t1.ZHH=t2.ZHH(+) and t2.ZHH is null
from TB_ZH_MONTH_BACKUP A
where A.NY = '当月'
and not Exists (
select *
from TB_ZH_MONTH_BACKUP B
where B.NY = '前月'
AND A.ZHH=B.ZHH
);
where t1.NY = '当月' and t2.NY = '前月' and t1.ZHH=t2.ZHH(+) and t2.ZHH is null