SELECT DISTINCT B.PLAN_TYPE , B.BENEFIT_PROGRAM , B.BENEFIT_PLAN , C.DESCR FROM PS_BEN_DEFN_PGM A , PS_BEN_DEFN_OPTN B , PS_BENEF_PLAN_TBL C WHERE A.EFF_STATUS = 'A' AND A.EFFDT = ( SELECT MAX(A_ED.EFFDT) FROM PS_BEN_DEFN_PGM A_ED WHERE A.BENEFIT_PROGRAM = A_ED.BENEFIT_PROGRAM AND A_ED.EFFDT <= %CurrentDateIn) AND B.BENEFIT_PROGRAM = A.BENEFIT_PROGRAM AND B.EFFDT = A.EFFDT AND B.OPTION_TYPE = 'O' AND B.OPTION_ID = ( SELECT MAX(B1.OPTION_ID) FROM PS_BEN_DEFN_OPTN B1 WHERE B1.BENEFIT_PROGRAM = B.BENEFIT_PROGRAM AND B1.OPTION_TYPE = 'O' AND B1.EFFDT = B.EFFDT AND B1.PLAN_TYPE = B.PLAN_TYPE AND B1.BENEFIT_PLAN = B.BENEFIT_PLAN) AND C.PLAN_TYPE = B.PLAN_TYPE AND C.BENEFIT_PLAN = B.BENEFIT_PLAN AND C.EFFDT = ( SELECT MAX(D.EFFDT) FROM PS_BENEF_PLAN_TBL D WHERE D.PLAN_TYPE = C.PLAN_TYPE AND D.BENEFIT_PLAN = C.BENEFIT_PLAN AND D.EFFDT <= A.EFFDT)
|