SELECT A.EMPLID ,B.BENEFIT_PLAN ,B.FUNCTN_RESULT_NM ,B.DESCR ,B.EACCT_FR_NAME ,C.SERVICE_FR_NAME FROM PS_PERSON A , PS_PA_FNC_RSLT_TBL B , PS_PA_EA_SV_FR_TBL C WHERE B.BENEFIT_PLAN = C.BENEFIT_PLAN AND B.FUNCTN_NAME = 'EMPLACCTS' AND B.FUNCTN_RESULT_NM = C.FUNCTN_RESULT_NM AND B.EACCT_TYPE = '2' AND B.FUNCTN_RESULT_NM NOT IN ( SELECT C.FUNCTN_RESULT_NM FROM PS_PA_EACCT_ACCUM C , PS_PA_FNC_RSLT_TBL D WHERE D.FUNCTN_NAME = 'EMPLACCTS' AND D.EACCT_TYPE = '2' AND C.EMPLID = A.EMPLID AND C.FUNCTN_RESULT_NM = D.FUNCTN_RESULT_NM AND C.END_BALANCE > 0 AND C.END_DATE = ( SELECT MAX(E.END_DATE) FROM PS_PA_EACCT_ACCUM E WHERE E.EMPLID = A.EMPLID AND E.FUNCTN_RESULT_NM = D.FUNCTN_RESULT_NM))
|