SELECT A.EMPLID , A.EMPL_RCD , A.INSTANCE , B.GPDE_LN_YEAR , B.GPDE_LN_MONTH , 'Y' FROM PS_GPDE_LN_SETUP A , PS_GPDE_LN_SCHED B WHERE A.EMPLID = B.EMPLID AND A.EMPL_RCD = B.EMPL_RCD AND A.INSTANCE = B.INSTANCE AND EXISTS ( SELECT 'X' FROM PS_GPDE_LN_RSLT RSLT WHERE RSLT.EMPLID = A.EMPLID AND RSLT.EMPL_RCD = B.EMPL_RCD AND RSLT.INSTANCE = B.INSTANCE AND RSLT.GPDE_LN_YEAR = B.GPDE_LN_YEAR AND RSLT.GPDE_LN_MONTH = B.GPDE_LN_MONTH AND RSLT.GPDE_LN_ACTIVE = 'Y' AND RSLT.GPDE_AL_CPAY_ENDDT = ( SELECT MAX(GPDE_AL_CPAY_ENDDT) FROM PS_GPDE_LN_RSLT sub WHERE sub.EMPLID = B.EMPLID AND sub.EMPL_RCD = B.EMPL_RCD AND sub.INSTANCE = B.INSTANCE AND sub.GPDE_LN_YEAR = B.GPDE_LN_YEAR AND sub.GPDE_LN_MONTH = B.GPDE_LN_MONTH) )
|