基础问题求教
有两个select语句 ,我想把它们结合起来并去重请教
select *from reportA where reportA.网元名称 not in (select reportB.网元名称 from reportB)
结果
a1NULLNULLNULLNULLNULLNULL
a2NULLNULLNULLNULLNULLNULL
另一个
select * from reportA where checksum(*) not in (select checksum(*) from reportB)
结果
3001-江南GE00000
3016-江北4E3/T300000
a1 NULLNULLNULLNULLNULLNULL
a2 NULLNULLNULLNULLNULLNULL
我想得到
3001-江南GE00000
3016-江北4E3/T300000
求教谢谢
[解决办法]
你这个有点误导啊,去重是要保留一条记录的,你的需求是有重复的数据都不保留
select * from (
select * from reportA where reportA.网元名称 not in (select reportB.网元名称 from reportB)
union all
select * from reportA where checksum(*) not in (select checksum(*) from reportB)
)a
group by 全部列名
having count(1)=1