SELECT C.CORT_NAME
, A.MRV_CORT_CODE
, SUM(CASE A.PYT_MTH_TYP WHEN '01' THEN A.CNT
ELSE 0 END) ACnt
, SUM(CASE A.PYT_MTH_TYP WHEN '01' THEN A.FIRS_PREM
ELSE 0 END) ASum
, SUM(CASE A.PYT_MTH_TYP WHEN '99' THEN A.CNT
ELSE 0 END) BCnt
, SUM(CASE A.PYT_MTH_TYP WHEN '99' THEN A.FIRS_PREM
ELSE 0 END) BSum
, SUM(CASE WHEN A.PYT_MTH_TYP NOT IN ('01', '99') THEN A.CNT
ELSE 0 END) CCnt
, SUM(CASE WHEN A.PYT_MTH_TYP NOT IN ('01', '99') THEN A.FIRS_PREM
ELSE 0 END) CSum
, SUM(A.CNT) TCnt
, SUM(A.FIRS_PREM) TSum
FROM TCCCPCN C
, (SELECT A.MRV_CORT_CODE, B.PYT_MTH_TYP, A.FIRS_PREM, 1 AS CNT
FROM TCIPREM A, TDGSBPR B
WHERE A.PAY_DAY BETWEEN '20050819' AND
'20050901'
AND A.CANC_FLAG is null
AND A.POLICY_NO = B.POLICY_NO
AND B.CONT_STA_COD IN ('00', '50','60')
UNION ALL
SELECT D.MRV_CORT_CODE, E.PYT_MTH_TYP,
(-D.FIRS_PREM) FIRS_PREM, -1 AS CNT
FROM TCIPREM D, TDGSBPR E
WHERE to_char(E.RENE_DTTM, '%Y%m%d') BETWEEN
'20050819' AND '20050901'
AND D.CANC_FLAG is null
AND D.POLICY_NO = E.POLICY_NO
AND E.CONT_STA_COD IN ('50', '60') ) A
WHERE C.CORT_CODE = A.MRV_CORT_CODE
GROUP BY A.MRV_CORT_CODE
, C.CORT_NAME
이런 쿼리가 있는데 인포믹스에서는
FROM TCCCPCN C
, (SELECT A.MRV_CORT....) A
이것때문에 에러가 나서요~~
좋은 방법 없을까요?
|