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 )
一个使用ROWNUM的别名来用
http://topic.csdn.net/u/20100719/13/b85e77e4-b916-4bac-9b91-70904bef918b.html