SELECT B.VENDOR_SETID AS SETID ,B.VENDOR_ID ,A.PERSON_ID ,A.NAME FROM PS_SPB_PERSON_TBL A , PS_SPB_SERVICE_PRV B , PSOPRALIAS C WHERE A.PERSON_ID = B.PERSON_ID AND (B.SP_FUNCTION_TYPE = 'PROV' OR B.SP_FUNCTION_TYPE = 'PRCT' OR B.SP_FUNCTION_TYPE = 'INDP') AND B.EFFDT = ( SELECT MAX(D.EFFDT) FROM PS_SPB_SERVICE_PRV D WHERE D.PERSON_ID = B.PERSON_ID AND D.SP_FUNCTION_TYPE = B.SP_FUNCTION_TYPE AND D.EFFDT <= %CurrentDateIn) AND C.PERSON_ID = A.PERSON_ID AND C.OPRALIASTYPE = 'SPP' AND A.USER_ACC_STATUS = '1'
|