hive报错:Both left and right alias
2019-06-04 本文已影响4人
JouyPub
错误原因:两个表join的时候,不支持两个表的字段的 非相等 操作。
解决办法:
1、把不相等条件拿到where语句中
select ... from
class_order t1
left join class_order_refund t2 on t1.orderdate>t2.orderdate
可以改写成
select ... from
class_order t1
left join class_order_refund t2
where t1.orderdate>t2.orderdate
2、如果第一中方法不适用,可以在select字段中判断
select
...
if(t1.orderdate>t2.orderdate,0,1) as is_refund
...
from
class_order t1
left join class_order_refund t2 on t1.orderdate>t2.orderdate
欢迎订阅「K叔区块链」 - 专注于区块链技术学习
博客地址:http://www.jouypub.com
简书主页:https://www.jianshu.com/u/756c9c8ae984
segmentfault主页:https://segmentfault.com/blog/jouypub
腾讯云主页:https://cloud.tencent.com/developer/column/72548