SELECT DISTINCT A.INSTITUTION , A.STRM , A.LANGUAGE_CD , A.DESCR , A.DESCRSHORT , B.DESCRFORMAL FROM %Table(TERM_TBL) A1 , %Table(TERM_TBL_LANG) A , %Table(INSTITUTION_TBL) B1 , %Table(INSTITUTION_LNG) B , %Table(SSR_STRM_CLS_VW) C1 WHERE A1.INSTITUTION = B1.INSTITUTION AND B1.EFFDT = ( SELECT MAX(EFFDT) FROM %Table(INSTITUTION_TBL) B2 WHERE B2.INSTITUTION = B1.INSTITUTION AND B2.EFFDT <= A1.TERM_BEGIN_DT) AND B1.EFF_STATUS = 'A' AND A1.INSTITUTION = C1.INSTITUTION AND A1.STRM = C1.STRM AND A1.INSTITUTION = A.INSTITUTION AND A1.STRM = A.STRM AND B1.INSTITUTION = B.INSTITUTION AND B1.EFFDT = B.EFFDT AND A.LANGUAGE_CD = B.LANGUAGE_CD UNION SELECT DISTINCT A.INSTITUTION , A.STRM , A.LANGUAGE_CD , A.DESCR , A.DESCRSHORT , B1.DESCRFORMAL FROM %Table(TERM_TBL) A1 , %Table(TERM_TBL_LANG) A , %Table(INSTITUTION_TBL) B1 , %Table(SSR_STRM_CLS_VW) C1 WHERE A1.INSTITUTION = B1.INSTITUTION AND B1.EFFDT = ( SELECT MAX(EFFDT) FROM %Table(INSTITUTION_TBL) B2 WHERE B2.INSTITUTION = B1.INSTITUTION AND B2.EFFDT <= A1.TERM_BEGIN_DT) AND B1.EFF_STATUS = 'A' AND A1.INSTITUTION = C1.INSTITUTION AND A1.STRM = C1.STRM AND A1.INSTITUTION = A.INSTITUTION AND A1.STRM = A.STRM AND NOT EXISTS ( SELECT 'X' FROM %Table(INSTITUTION_LNG) B WHERE B.INSTITUTION = B1.INSTITUTION AND B.EFFDT = B1.EFFDT AND B.LANGUAGE_CD = A.LANGUAGE_CD) UNION SELECT DISTINCT A1.INSTITUTION , A1.STRM , B.LANGUAGE_CD , A1.DESCR , A1.DESCRSHORT , B.DESCRFORMAL FROM %Table(TERM_TBL) A1 , %Table(INSTITUTION_TBL) B1 , %Table(INSTITUTION_LNG) B , %Table(SSR_STRM_CLS_VW) C1 WHERE A1.INSTITUTION = B1.INSTITUTION AND B1.EFFDT = ( SELECT MAX(EFFDT) FROM %Table(INSTITUTION_TBL) B2 WHERE B2.INSTITUTION = B1.INSTITUTION AND B2.EFFDT <= A1.TERM_BEGIN_DT) AND B1.EFF_STATUS = 'A' AND A1.INSTITUTION = C1.INSTITUTION AND A1.STRM = C1.STRM AND B1.INSTITUTION = B.INSTITUTION AND B1.EFFDT = B.EFFDT AND NOT EXISTS ( SELECT 'X' FROM %Table(TERM_TBL_LANG) A WHERE A.INSTITUTION = A1.INSTITUTION AND A.STRM = A1.STRM AND A.LANGUAGE_CD = B.LANGUAGE_CD)
|