hive left outer join问题

来源:互联网 发布:北海广电网络客服电话 编辑:程序博客网 时间:2024/05/20 13:12
select * FROM t_xg_product a join t_xg_product_subject_mapping m on (m.product_id=a.product_id)
left outer join 
(select (case when d.product_id is null then '' else cast(d.product_id as string) end) as product_id,
(case when count(1) > 0 then count(1) else cast(0 as bigint) end) as order_num_i 
from src_xg_ordr_item d where substr_split(substr(d.create_time,0,10),'-',0,2,'')='20130805' group by d.product_id) e on (a.product_id=e.product_id)

;


left outer join 的时候  on的条件 (a.product_id=e.product_id)两个product_id的类型必须是一样的,不然就是等价匹配,而不是左联接匹配

原创粉丝点击