다음은 GreenPlum에 대한 다중 하위 쿼리가있는 SQL입니다. 불행히도 SQL을 Hive로 마이그레이션해야하지만 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_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
귀하의 팁에 감사드립니다.
당신은 변환해야합니다 subquery
과를 in clause
에
왼쪽 외부 결합
구조에 초점 :
select <cols list>
from <tabname> t
left outer join dw_stage.wms_c_wlsjd w
on w.lydjh = t.wljhdh
where w.lzztflag='上架确认'
그만큼
((t.ckid,t.supp_num) in (select .. )
과
supp_num not in (select distinct vndr_code as supp_no
것 또한 외부 조인으로 다시 작성해야합니다.
이 다른 질문에 대한 내 대답에서 외부 조인 사용에 대한 자세한 정보를 찾을 수 있습니다. NOT IN 절을 실행하는 Hive 명령
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다