select id,q3 from (
select m1.id,nvl(m1.q1,0)-nvl(m2.q2,0) q3
from (select id,sum(qian) q1 from 30money group by id) m1
left join (select id,sum(qian) q2 from 23money group by id) m2 on (m1.id=m2.id)) order by q3 asc
) where rownum <=10
希望对你有帮助
思路:可以用union all 查出所有id group by 后 having 统计为1的即为不同数据,为2的则为相同数据
https://blog.csdn.net/luyaran/article/details/80928666
select t1.*, t2.*from 真实表 t1 full join 临时表 using (id) //using也可写成on t1.id=t2.id
where t1.f!=t2.f or (t1.f is null and t2.f is not null) or (t1.f is not null and t2.f is null)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)