SELECT DISTINCT oprdef.OPRID , todo.EMPLID , todo.INSTITUTION , todo.DESCR2 FROM PS_SRVCIND_TODO_VW todo , PSOPRDEFN oprdef UNION SELECT DISTINCT a.OPRID , cntx1.SCC_TM_KEY_VALUE EMPLID , cntx2.SCC_TM_KEY_VALUE INSTITUTION , E.DESCR FROM ps_SCC_TM_ACTTSKVW A , ps_SCC_TM_PTAICNTX cntx1 , ps_SCC_TM_PTAICNTX cntx2 , PS_INSTITUTION_TBL E WHERE cntx1.SCC_TM_LIST_ID =A.SCC_TM_LIST_ID AND cntx1.SCC_TM_CTX_KEY='Y' AND cntx1.FIELDNAME ='EMPLID' AND cntx2.SCC_TM_LIST_ID =A.SCC_TM_LIST_ID AND cntx2.SCC_TM_CTX_KEY='Y' AND cntx2.FIELDNAME ='INSTITUTION' AND cntx2.SCC_TM_KEY_VALUE= E.INSTITUTION AND E.EFF_STATUS = 'A' AND E.EFFDT = ( SELECT MAX(E1.EFFDT) FROM PS_INSTITUTION_TBL E1 WHERE E1.INSTITUTION = cntx2.SCC_TM_KEY_VALUE AND E1.EFFDT <= %CurrentDateIn)
|