select NY||ZHH from TB_ZH_MONTH_BACKUP where NY = '当月' and not Exists (select * from TB_ZH_MONTH_BACKUP where NY = '前月')
...全文
654打赏收藏
请帮忙看看我的sql 语句合理不合理?
需求:查询数据表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
);