其他sql格式也在更新中,可直接查看俺的这个系列,要是没有你需要的格式,可在评论或私信我,俺现在一天一看
子查询中有子查询
oracle 原sql
select
nvl((select ld.targetcode
from B ld
where ld.codetype = 'bankcode'
and ld.basiccode =
(select l.bankcode
from C l
where l.contno = lj.policyno)),
0) as bankcode
from
A lj
hive 改sql
select
nvl(lding.targetcode,0) as bankcode
from
A lj
LEFT JOIN
C lc
on lc.contno = pro.policyno
LEFT JOIN
B lding
on lding.codetype = 'bankcode'
and lding.basiccode = lc.bankcode
过程:先把c的子查询拿出来,在用b表去关联一下就好了
版权声明:本文为zzydan0原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。