SELECT DISTINCT R2.RUN_TYPE , R2.EFFDT , R1.DESCR , R2.PIN_PRC_NUM ,PIN.COUNTRY ,PIN2.PIN_NUM FROM PS_GP_RUN_TYPE R1 , PS_GP_RUN_TYPE_DTL R2 , PS_GP_PIN PIN , PS_GP_PIN PIN2 , PS_GP_COUNTRY C , PS_GP_PROCESS P WHERE R1.RUN_TYPE = R2.RUN_TYPE AND R1.CALC_TYPE = 'P' AND R2.EFF_STATUS = 'A' AND R2.EFFDT = ( SELECT MAX(R3.EFFDT) FROM PS_GP_RUN_TYPE_DTL R3 WHERE R3.RUN_TYPE = R2.RUN_TYPE AND R3.EFFDT <= %CurrentDateIn) AND PIN.PIN_NUM = R2.PIN_PRC_NUM AND (PIN.USED_BY = 'A' OR (PIN.USED_BY = 'C' AND C.COUNTRY = PIN.COUNTRY)) AND P.PIN_NUM=R2.PIN_PRC_NUM AND P.EFF_STATUS='A' AND P.EFFDT = ( SELECT MAX(P2.EFFDT) FROM PS_GP_PROCESS P2 WHERE P2.PIN_NUM = P.PIN_NUM AND P2.EFFDT <= %CurrentDateIn) AND (PIN2.PIN_NUM= P.PIN_GROSS_NUM OR PIN2.PIN_NUM=P.PIN_NET_NUM)
|