I'm trying to run the query below; however I get the following 2 errors:
1) Number (156) Severity (15) State (68) Server (SYBASE) Incorrect syntax near the keyword 'UNION'.
2) Number (102) Severity (15) State (1) Server (SYBASE) Incorrect syntax near ')'.
The subquery runs successfully by itself.
I'm not seeing the syntax error. Any assistance would be appreciated.
SELECT A.MEME_CK, MIN(A.MEPE_EFF_DT) , MAX(A.MEPE_TERM_DT)
FROM CMC_MEPE_PRCS_ELIG A
WHERE A.MEME_CK IN
(
SELECT B.MEME_CK
FROM HHT_CMS_MSP_DTL_WORK B
where CAST( SUBSTRING(B.MEPE_TERM_DT, 1, 4) + '-' + SUBSTRING(B.MEPE_TERM_DT, 5, 2) + '-' + SUBSTRING(B.MEPE_TERM_DT, 7, 2) AS DATETIME) > '10/31/2010'
AND B.MEPE_TERM_DT != '00000000'
UNION
SELECT C.MEME_CK
FROM HHT_CMS_MSP_DTL_WORK C
where C.MEPE_TERM_DT = '00000000'
)
AND A.CSPD_CAT = 'M'
AND A.MEPE_ELIG_IND = 'Y'
GROUP BY A.MEME_CK
1) Number (156) Severity (15) State (68) Server (SYBASE) Incorrect syntax near the keyword 'UNION'.
2) Number (102) Severity (15) State (1) Server (SYBASE) Incorrect syntax near ')'.
The subquery runs successfully by itself.
I'm not seeing the syntax error. Any assistance would be appreciated.
SELECT A.MEME_CK, MIN(A.MEPE_EFF_DT) , MAX(A.MEPE_TERM_DT)
FROM CMC_MEPE_PRCS_ELIG A
WHERE A.MEME_CK IN
(
SELECT B.MEME_CK
FROM HHT_CMS_MSP_DTL_WORK B
where CAST( SUBSTRING(B.MEPE_TERM_DT, 1, 4) + '-' + SUBSTRING(B.MEPE_TERM_DT, 5, 2) + '-' + SUBSTRING(B.MEPE_TERM_DT, 7, 2) AS DATETIME) > '10/31/2010'
AND B.MEPE_TERM_DT != '00000000'
UNION
SELECT C.MEME_CK
FROM HHT_CMS_MSP_DTL_WORK C
where C.MEPE_TERM_DT = '00000000'
)
AND A.CSPD_CAT = 'M'
AND A.MEPE_ELIG_IND = 'Y'
GROUP BY A.MEME_CK