2017-07-19 40 views
0

當我運行下面的查詢時,我得到的錯誤。如何在配置單元中使用兩個子查詢

FAILED: SemanticException [Error 10249]: Line 13:15 Unsupported SubQuery Expression 'master_cd': Only 1 SubQuery expression is supported. 

SELECT 
cfs.roll_no, 
max(cclas.crdm_cd) as crdm_cd, 
max(cclas.kjtm_cd) as kjtm_cd 
FROM cust_focus cfs 
LEFT JOIN cust_class cclas 
ON (cfs.CF_CLAS_NO = cclas.CLAS_NO 
AND cfs.DFS_CD = cclas.DFS_CD 
AND cclas.D_AREA = 'US' 
AND cclas.active_flag = 'Y') 
WHERE cfs.roll_no NOT IN (SELECT roll_no FROM class_hist) 
AND UPPER(TRIM(cfs.D_AREA)) = 'US' 
AND (cfs.master_cd IN (SELECT msk5.msk5_master_cd from msk5_mst_tbl as msk5 WHERE cfs.master_cd=msk5.msk5_master_cd and msk5_m_code=9) 
OR cfs.master_cd IS NULL) 
group by cfs.roll_no; 

請幫我解決這個問題。

在此先感謝。

回答

0

您可以用加入

... 
from 
cust_focus cfs 
... 
left join msk5_mst_tbl msk5 
    on cfs.master_cd=msk5.msk5_master_cd 
    and msk5_m_code=9 
取代你的第二子查詢 (SELECT msk5.msk5_master_cd from msk5_mst_tbl as msk5 WHERE cfs.master_cd=msk5.msk5_master_cd and msk5_m_code=9)
相關問題