原来在oracle 里面的SQL语句,
insert into tmp_t_mz_ry_jhdj_add
select a.*
from tmp_t_mz_ry_jhdj a
left join t_jztp_gx_sum b on ((a.zgxr = b.zgxr and a.cgxr = b.cgxr) or
(a.zgxr = b.cgxr and a.cgxr = b.zgxr))
and b.gxxl like '1104%'
left join tmp_t_mz_ry_lhdj c on a.zgxr = c.zgxr
and a.cgxr = c.cgxr
and a.gxfssj < c.gxfssj
where b.zgxr is null
and c.zgxr is null;
在left join on条件中存在不等值查询,maxcompute left outer join不支持,但是表的数据量都非常大,用map join不合适,怎样修改SQL ,实现原来的效果
把不等值放在关联之后的where中过滤,把b、c表中的过滤条件提到子查询中提前过滤数据量,减少join的数据量,望采纳,谢谢!
select a.*
from
(select * from tmp_t_mz_ry_jhdj)a
left join
(select * from t_jztp_gx_sum where gxxl like '1104%' and zgxr is null)b
on ((a.zgxr = b.zgxr and a.cgxr = b.cgxr) or
(a.zgxr = b.cgxr and a.cgxr = b.zgxr))
left join
(select * from tmp_t_mz_ry_lhdj where zgxr is null)c
on a.zgxr = c.zgxr
and a.cgxr = c.cgxr
where a.gxfssj < c.gxfssj;
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。