5,889
社区成员
发帖
与我相关
我的任务
分享
select * from
(
select ID,RQ, sum(SL) A_SL from TA where nd='2009' group by ID,RQ
union
select ID,RQ, sum(SL) B_SL from TB where nd='2009' group by ID,RQ
) as x
where id not in
(select ta.id from ta,tb where ta.ID = tb.id and ta.RQ = tb.RQ and ta.SL = tb.SL and ta.nd = tb.nd and ta.nd='2009')
select * from
(
select ID,RQ, sum(SL) A_SL from TA where nd='2009' group by ID,RQ
union
select ID,RQ, sum(SL) B_SL from TB where nd='2009' group by ID,RQ
) as x
where id not in
(
select a.id from
(
select ID,RQ, sum(SL) A_SL from TA where nd='2009' group by ID,RQ
) as a inner join
(
select ID,RQ, sum(SL) B_SL from TB where nd='2009' group by ID,RQ
) as b on a.ID = b.ID and a.RQ = b.RQ and a.A_SL = b.B_SL)