[Amazon](500310) Invalid operation: This type of IN/NOT IN query is not supported yet;

后端 未结 1 1148
一整个雨季
一整个雨季 2021-01-27 18:08

I\'m converting this query from Netezza to run with my RedShift dw. I\'m continuously getting this error.

Amazon Invalid operation: This type of IN/NOT IN query is not s

相关标签:
1条回答
  • 2021-01-27 18:29

    You have constant values in where clause, you don't need exists clause.

    Can you try below -

    CREATE TEMP TABLE TMP_EMPLY_BRND AS 
    (
    Select EMPLY_SRRGT_ID,
               EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_STRT_DT_KEY,
               EMPLY_PRMRY_PRDCT_DPRTMNT_GRP_SRRGT_ID,
    
    From           
    ((
     (SELECT E.EMPLY_SRRGT_ID,
               E.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_STRT_DT_KEY,
        FROM INS_EDW_CP.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT E
        where (((E.EMPLY_SRRGT_ID, E.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_STRT_DT_KEY, E.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_END_DT_KEY )=ANY
              (SELECT distinct A.EMPLY_SRRGT_ID , A.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_STRT_DT_KEY, A.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_END_DT_KEY
               FROM INS_EDW_CP.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT A
               WHERE (A.EMPLY_PRMRY_BRND_SRRGT_ID > 0 )
               GROUP BY A.EMPLY_SRRGT_ID , A.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_STRT_DT_KEY, A.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_END_DT_KEY
               HAVING ((COUNT(DISTINCT A.EMPLY_PRMRY_PRDCT_DPRTMNT_GRP_SRRGT_ID) > 1)
                       AND (COUNT(DISTINCT A.EMPLY_PRMRY_BRND_SRRGT_ID) = 1))))
                      or ((E.EMPLY_MRCHNDS_GRP_NBR , E.EMPLY_PRMRY_BRND_SRRGT_ID)  in  ( 947,-1)
                       or  (E.EMPLY_MRCHNDS_GRP_NBR , E.EMPLY_PRMRY_BRND_SRRGT_ID) in  ( 952,-1) ))
        Group BY
        E.EMPLY_SRRGT_ID, 
    UNION
    SELECT E.EMPLY_SRRGT_ID,
               E.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_STRT_DT_KEY,
        FROM INS_EDW_CP.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT E
        where    (
        ((E.EMPLY_SRRGT_ID, E.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_STRT_DT_KEY, E.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_END_DT_KEY )<>ALL
              (SELECT distinct A.EMPLY_SRRGT_ID , A.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_STRT_DT_KEY, A.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_END_DT_KEY
               FROM INS_EDW_CP.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT A
               WHERE (A.EMPLY_PRMRY_BRND_SRRGT_ID > 0 )
               GROUP BY A.EMPLY_SRRGT_ID , A.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_STRT_DT_KEY, A.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_END_DT_KEY
               HAVING ((COUNT(DISTINCT A.EMPLY_PRMRY_PRDCT_DPRTMNT_GRP_SRRGT_ID) > 1)
                       AND (COUNT(DISTINCT A.EMPLY_PRMRY_BRND_SRRGT_ID) = 1)))
                       )
                       and ((E.EMPLY_MRCHNDS_GRP_NBR,E.EMPLY_PRMRY_BRND_SRRGT_ID) not in  ( 947,-1)
                       and (E.EMPLY_MRCHNDS_GRP_NBR,E.EMPLY_PRMRY_BRND_SRRGT_ID) not in  ( 952,-1)))
    ) X
    JOIN INS_EDW_CP.DT D1 
    ON D1.DT_KEY between X.EMPLY_PRMRY_BRND_PRDCT_DPRTMNT_EFF_STRT_DT_KEY and X.EFF_END_DT_KEY
    JOIN INS_EDW_CP.DT_CLNDR_TYPE D2
    on ((D1.DT_KEY = D2.DT_KEY) AND (D2.CLNDR_TYPE = 1)))
    );
    
    0 讨论(0)
提交回复
热议问题