SELECT A.BUSINESS_UNIT , A.PROJECT_ID , A.LOCATION , D.DESCR FROM PS_PROJ_LOCATION A , PS_LOCATION_TBL D , PS_SET_CNTRL_REC E WHERE A.EFFDT = ( SELECT MAX(B.EFFDT) FROM PS_PROJ_LOCATION B WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.PROJECT_ID = B.PROJECT_ID AND B.EFFDT <= %CurrentDateIn) AND A.EFFSEQ = ( SELECT MAX(C.EFFSEQ) FROM PS_PROJ_LOCATION C WHERE A.BUSINESS_UNIT = C.BUSINESS_UNIT AND A.PROJECT_ID = C.PROJECT_ID AND A.EFFDT = C.EFFDT) AND D.EFFDT = ( SELECT MAX(L.EFFDT) FROM PS_LOCATION_TBL L WHERE D.SETID = L.SETID AND D.LOCATION = L.LOCATION AND D.EFFDT <= %CurrentDateIn) AND D.SETID = E.SETID AND D.LOCATION = A.LOCATION AND E.SETCNTRLVALUE = A.BUSINESS_UNIT AND E.RECNAME = 'LOCATION_TBL'
|