SELECT DISTINCT A.INSTITUTION , A.SSR_RI_EDU_GOV_NLD , B.LOCATION , CASE WHEN LENGTH(B.ESTABID) = 7 THEN B.ESTABID END , B2.EFFDT , CASE WHEN B.EFF_STATUS = 'I' THEN B.EFFDT END , CASE WHEN B.COUNTRY = 'NLD' THEN B.POSTAL END , CASE WHEN B.COUNTRY = 'NLD' THEN B.NUM1 END , CASE WHEN B.COUNTRY = 'NLD' THEN B.NUM2 END , ' ' , COALESCE(D.SCC_LATITUDE , NULL) , COALESCE(D.SCC_LONGITUDE , NULL) FROM %Table(SSR_RI_EPS_NLD) A JOIN %Table(CAMPUS_TBL) C ON A.INSTITUTION = C.INSTITUTION JOIN %Table(LOCATION_TBL) B ON C.LOCATION = B.LOCATION JOIN %Table(SSR_RI_OLWL_NLD) OLW ON A.INSTITUTION = OLW.INSTITUTION AND B.LOCATION = OLW.LOCATION LEFT OUTER JOIN %Table(BLDG_TBL) D ON B.BUILDING = D.BLDG_CD JOIN %Table(LOCATION_TBL) B2 ON B.SETID = B2.SETID AND B.LOCATION = B2.LOCATION JOIN %Table(SET_CNTRL_REC) E ON A.INSTITUTION = E.SETCNTRLVALUE AND E.RECNAME = 'LOCATION_TBL' AND E.SETID = B.SETID WHERE %EffdtCheck(CAMPUS_TBL C1, C, %currentdatein) AND B.EFFDT = ( SELECT MAX(B_ED.EFFDT) FROM %Table(LOCATION_TBL) B_ED WHERE B.SETID = B_ED.SETID AND B.LOCATION = B_ED.LOCATION AND B_ED.EFFDT <= %CurrentDateIn ) AND B2.EFFDT = ( SELECT MIN(B2_ED.EFFDT) FROM %Table(LOCATION_TBL) B2_ED WHERE B.SETID = B2_ED.SETID AND B.LOCATION = B2_ED.LOCATION AND B2_ED.EFF_STATUS = 'A' ) AND %EffdtCheck(SSR_RI_EPS_NLD A_ED,A,%CURRENTDATEIN) AND A.EFFDT = OLW.EFFDT
|