我有一个如下查询:
SELECT T.MTH_END_DT, T.SRC_SYS_CD, T.BTCH_ID
FROM PROD_RCRR.BAL_CNTRL_LOG T
WHERE T.SRC_SYS_CD='SL'
AND T.MTH_END_DT in (SELECT(MAX(MTH_END_DT)) FROM PROD_RCRR.BAL_CNTRL_LOG)
AND T.BTCH_ID in (SELECT(MAX(BTCH_ID )) FROM PROD_RCRR.BAL_CNTRL_LOG)
错误消息显示Hive只能支持一个“in”子句。任何人都可以给我一个解决方案吗?
答案 0 :(得分:2)
您可以使用Join ON子句
替换整个事物SELECT
T.MTH_END_DT
, T.SRC_SYS_CD
, T.BTCH_ID
FROM PROD_RCRR.BAL_CNTRL_LOG T
JOIN ( SELECT
MAX(MTH_END_DT) ENDT
, MAX(BTCH_ID ) BTCH
FROM PROD_RCRR.BAL_CNTRL_LOG ) X
ON T.SRC_SYS_CD='SL'
AND T.MTH_END_DT = X.ENDT
AND T.BTCH_ID = X.BTCH