SELECT DISTINCT A.SSR_BR_INDEX_ID ,A.SSR_BR_MSGUUID ,A.SSR_BR_RESL_SQ_NLD ,A.HEGIS_CODE ,A.EMPLID , A.SSR_BR_TRANS_DTTM ,( SELECT COUNT(*) FROM PS_SSR_BR_IDER_NLD B WHERE A.SSR_BR_INDEX_ID =B.SSR_BR_INDEX_ID AND A.SSR_BR_MSGUUID=B.SSR_BR_MSGUUID )"ERRORS" FROM PS_SSR_BR_DPBO_NLD A WHERE A.SSR_BR_ACCEPTED='N' AND NOT EXISTS ( SELECT 'X' FROM PS_SSR_BR_ERDP_NLD B WHERE B.SSR_BR_INDEX_ID=A.SSR_BR_INDEX_ID AND B.SSR_BR_MSGUUID=A.SSR_BR_MSGUUID AND B.SSR_BR_RESL_SQ_NLD=A.SSR_BR_RESL_SQ_NLD AND B.HEGIS_CODE=A.HEGIS_CODE AND B.EMPLID=A.EMPLID AND B.REJECT_FLAG='R' ) AND A.SSR_BR_TRANS_DTTM = ( SELECT MAX(C.SSR_BR_TRANS_DTTM) FROM PS_SSR_BR_DPBO_NLD C WHERE C.EMPLID=A.EMPLID AND C.SSR_BR_RESL_SQ_NLD=A.SSR_BR_RESL_SQ_NLD AND C.HEGIS_CODE=A.HEGIS_CODE) GROUP BY A.SSR_BR_INDEX_ID,A.SSR_BR_MSGUUID ,A.SSR_BR_RESL_SQ_NLD ,A.HEGIS_CODE ,A.EMPLID, A.SSR_BR_TRANS_DTTM
|