SELECT A.INSTITUTION , A.SSR_RI_EDU_GOV_NLD , B.ACAD_ORG , B2.EFFDT , CASE WHEN B.EFF_STATUS = 'I' THEN B.EFFDT END , C.SCC_CAF_ATTR_VAL FROM %Table(SSR_RI_EPS_NLD) A JOIN %Table(ACAD_ORG_TBL) B ON A.INSTITUTION = B.INSTITUTION JOIN %Table(SSR_RI_EPWL_NLD) EPW ON B.INSTITUTION = EPW.INSTITUTION AND B.ACAD_ORG = EPW.ACAD_ORG JOIN %Table(ACAD_ORG_TBL) B2 ON B.ACAD_ORG = B2.ACAD_ORG LEFT OUTER JOIN %Table(ACAD_ORG_CAF) C ON A.SCC_CAF_ATTRIB_NM = C.SCC_CAF_ATTRIB_NM AND B.ACAD_ORG = C.ACAD_ORG WHERE B.EFFDT = ( SELECT MAX(B_ED.EFFDT) FROM %Table(ACAD_ORG_TBL) B_ED WHERE B.ACAD_ORG = B_ED.ACAD_ORG AND B_ED.EFFDT <= %CurrentDateIn) AND B2.EFFDT = ( SELECT MIN(B2_ED.EFFDT) FROM %Table(ACAD_ORG_TBL) B2_ED WHERE B.ACAD_ORG = B2_ED.ACAD_ORG AND B2_ED.EFFDT <= %CurrentDateIn AND B2_ED.EFF_STATUS = 'A' ) AND (C.EFFDT = ( SELECT MIN(C_ED.EFFDT) FROM %Table(ACAD_ORG_CAF) C_ED WHERE C.ACAD_ORG = C_ED.ACAD_ORG) OR C.EFFDT IS NULL) AND %EffdtCheck(SSR_RI_EPS_NLD A_ED,A,%CURRENTDATEIN) AND A.EFFDT = EPW.EFFDT
|