oracle sql 转换成 hive sql -子查询转关联查询(十六),hive的nvl中的子查询

其他sql格式也在更新中,可直接查看这个系列,要是没有你需要的格式,可在评论或私信我

hive的nvl中的子查询

oracle 原sql

select
 nvl(
	(select b.code
	from B b
	where b.codetype = '123'
	and b.code = a.code),
		'000000') as code
from
	A a

hive 改sql

select
 nvl(b.code,'000000') as code
from
	A a
	left join B b 
	on	b.codetype = '123'
	and b.code = a.code
hive的nvl中的双重子查询

oracle 原sql

select
 nvl(
	(select b.code
	from B b
	where b.codetype = '123'
	and b.code = a.code),
	(select c.code
	from C c
	where c.codetype = '123'
	and c.code = a.code)) as code
from
	A a

hive 改sql

select
 nvl(b.code,c.code) as code
from
	A a
	left join B b 
	on	b.codetype = '123'
	and b.code = a.code
	left join C c 
	on	c.codetype = '123'
	and c.code = a.code
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值