SELECT B.PAY_END_DT ,A.EMPLID ,A.EMPL_RCD ,A.COMPANY ,A.PAYGROUP , B.CHECK_DT FROM PS_JOB A ,PS_PAY_CALENDAR B ,PS_PAYGROUP_TBL C WHERE B.PAY_OFF_CYCLE_CAL = 'N' AND B.PAY_OFF_CYCLE_CLS = 'N' AND B.RUN_ID <> ' ' AND A.EFFDT= ( SELECT MAX(D.EFFDT) FROM PS_JOB D WHERE A.EMPLID=D.EMPLID AND A.EMPL_RCD=D.EMPL_RCD AND D.EFFDT<= B.PAY_END_DT) AND A.EFFSEQ= ( SELECT MAX(E.EFFSEQ) FROM PS_JOB E WHERE A.EMPLID=E.EMPLID AND A.EMPL_RCD=E.EMPL_RCD AND A.EFFDT=E.EFFDT) AND A.COMPANY=B.COMPANY AND A.PAYGROUP=B.PAYGROUP AND B.COMPANY=C.COMPANY AND B.PAYGROUP=C.PAYGROUP AND C.COUNTRY <> 'CAN' AND C.EFFDT= ( SELECT MAX(F.EFFDT) FROM PS_PAYGROUP_TBL F WHERE C.COMPANY=F.COMPANY AND C.PAYGROUP=F.PAYGROUP AND F.EFFDT <= B.PAY_END_DT)
|