如何在hive中使用两个子查询

时间:2017-07-19 14:20:21

标签: hive

当我在查询下运行时,我收到错误。

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;

请帮我解决此问题。

提前致谢。

1 个答案:

答案 0 :(得分:0)

您可以使用联接

替换第二个子查询name Company doj Justin
(SELECT msk5.msk5_master_cd from msk5_mst_tbl as msk5 WHERE cfs.master_cd=msk5.msk5_master_cd and msk5_m_code=9)