Hive 如何在配置单元中使用多个子查询重写sql
下面是一个针对GreenPlum的带有多个子查询的SQL。不幸的是,我必须将SQL迁移到配置单元,我不知道如何在WHERE子句中处理这些子查询Hive 如何在配置单元中使用多个子查询重写sql,hive,subquery,Hive,Subquery,下面是一个针对GreenPlum的带有多个子查询的SQL。不幸的是,我必须将SQL迁移到配置单元,我不知道如何在WHERE子句中处理这些子查询 select t.ckid , t.prod_id , t.supp_num , t.wljhdh , sum(t.sssl) as zmkc , max(t.dj) as dj from %s t where exists (select 1 from dw_stage.wms_c_wls
select
t.ckid , t.prod_id , t.supp_num , t.wljhdh ,
sum(t.sssl) as zmkc , max(t.dj) as dj
from
%s t
where
exists (select 1
from dw_stage.wms_c_wlsjd w
where w.lydjh = t.wljhdh and w.lzztflag='上架确认'
and (ckid , kqid) in (select ckid , kqid
from dw_stage.jcxx_kqxx
where kqytsxid in ('2','3'))
)
and (t.ckid,t.supp_num) in (select cgck_stock_id,vndr_code from madfrog.cfg_vendor_dist where status=1 and send_method=2 and upper(purch_warehouse_type)='F')
and supp_num not in (select distinct vndr_code as supp_no from madfrog.cfg_vendor_dist where status=1 and send_method in (4,5))
group by t.ckid , t.prod_id , t.supp_num , t.wljhdh
谢谢您的提示。您需要将
子查询
和in子句
转换为
左外连接
关注结构:
select <cols list>
from <tabname> t
left outer join dw_stage.wms_c_wlsjd w
on w.lydjh = t.wljhdh
where w.lzztflag='上架确认'
及
也需要作为外部联接重写
您可以在我对另一个问题的回答中找到有关使用外部联接的更多信息:您需要将
子查询和in子句转换为
左外连接
关注结构:
select <cols list>
from <tabname> t
left outer join dw_stage.wms_c_wlsjd w
on w.lydjh = t.wljhdh
where w.lzztflag='上架确认'
及
也需要作为外部联接重写
您可以在我对另一个问题的回答中找到有关使用外部联接的更多信息:hiveClient版本是1.2.1您在hive中尝试过吗?hiveClient版本是1.2.1您在hive中尝试过吗?谢谢!到目前为止,我还没有找到解决这类问题的其他方法,我将尝试您的解决方案。谢谢!到目前为止,我还没有找到解决这类问题的其他方法,我将尝试你的解决方案。
supp_num not in (select distinct vndr_code as supp_no