SELECT DISTINCT B.VENDOR_SETID AS SETID ,B.VENDOR_ID ,D.PERSON_ID ,A.NAME FROM PS_SPB_PERSON_TBL A , PS_SPB_SERVICE_PRV B , PS_SPF_WORDERREC C , PSOPRALIAS D WHERE A.PERSON_ID = B.PERSON_ID AND A.PERSON_ID = C.WO_CONID AND A.PERSON_ID = D.PERSON_ID AND (B.SP_FUNCTION_TYPE IN ('INDP','PROV')) AND B.ACTIVE_FLG = 'Y' AND (A.SPRO_PERSON_TYPE = 'SP' OR A.SPRO_PERSON_TYPE = 'PC') AND D.OPRALIASTYPE = 'SPP' AND B.EFFDT = ( SELECT MAX(E.EFFDT) FROM PS_SPB_SERVICE_PRV E WHERE E.PERSON_ID = B.PERSON_ID AND E.SP_FUNCTION_TYPE = B.SP_FUNCTION_TYPE AND E.EFFDT <= %CurrentDateIn) AND A.USER_ACC_STATUS <> '0'
|