1、
update employee a set a.dept_id=(
 select decode(dept_id,null,'0',dept_id) from
   ( 
      select dept_id,rownum as rid from nm_dept_user 
       where user_id=(select user_id from nm_user where re=a.emp_id)
   )
  where rid=1
)
where companyflag='0' and dept_id not in( select dept_id from nm_dept ) 
2、
update employee a set a.dept_id=
   (
       select decode(dept_id,null,'0',dept_id) from nm_dept_user 
       where user_id=(select user_id from nm_user where re=a.emp_id)
         and rownum=1
   )
where companyflag='0' and dept_id not in( select dept_id from nm_dept )