select ID, MEMO, REALNAME, FID, PARTLIST, DUTY, FNAME
from OA_EMPLOYEES_VIEW
where ((FID in (select id from oa_depart t where ','||plist||',' like'%,18,%') and
(',' || PARTLIST || ',-1' like '%,147,%')) or --代维人员
(FID in
(select id from oa_depart t where ','||plist||',' like'%,17,%') and
(',' || PARTLIST || ',-1' like '%,139,%' or --工程管理
',' || PARTLIST || ',-1' like '%,144,%' )) --施工队
or (FID in
(select id from oa_depart t where ','||plist||',' like'%,1,%') and
( ',' || PARTLIST || ',-1' like '%,145,%' ))) --设计院
order by FID, duty