SELECT A.BENEFIT_PROGRAM , A.EFFDT , A.PLAN_TYPE , B.OPTION_ID , C.COST_ID FROM PS_BEN_DEFN_PLAN A , PS_BEN_DEFN_OPTN B , PS_BEN_DEFN_COST C WHERE A.EFFDT = ( SELECT MAX(A_ED.EFFDT) FROM PS_BEN_DEFN_PLAN A_ED WHERE A.BENEFIT_PROGRAM = A_ED.BENEFIT_PROGRAM AND A_ED.EFFDT <= SYSDATE) AND A.BENEFIT_PROGRAM = B.BENEFIT_PROGRAM AND A.PLAN_TYPE = B.PLAN_TYPE AND B.EFFDT = ( SELECT MAX(B_ED.EFFDT) FROM PS_BEN_DEFN_OPTN B_ED WHERE B.BENEFIT_PROGRAM = B_ED.BENEFIT_PROGRAM AND B_ED.EFFDT <= SYSDATE) AND A.BENEFIT_PROGRAM = C.BENEFIT_PROGRAM AND A.PLAN_TYPE = C.PLAN_TYPE AND C.EFFDT = ( SELECT MAX(C_ED.EFFDT) FROM PS_BEN_DEFN_COST C_ED WHERE C.BENEFIT_PROGRAM = C_ED.BENEFIT_PROGRAM AND C_ED.EFFDT <= SYSDATE) AND NOT EXISTS ( SELECT D.BENEFIT_PROGRAM FROM PS_BEN_DEFN_PGM D WHERE D.EFFDT = ( SELECT MAX(D_ED.EFFDT) FROM PS_BEN_DEFN_PGM D_ED WHERE D.BENEFIT_PROGRAM = D_ED.BENEFIT_PROGRAM AND D_ED.EFFDT <= SYSDATE))
|