SQL> select *from sales_info;
EMPLOYEE_ID WEEK SALES
----------- ---------- ----------
176 6 1000
176 6 1000
176 6 1000
176 6 1000
176 6 1000
这样表,如何将 update 第三行 的week 列 的值从 6设为1
SQL> update sales_info set week=decode(rownum,3,1,6) where rownum < 4;
已更新3行。
SQL> select * from sales_info;
EMPLOYEE_ID WEEK SALES
----------- ---------- ----------
176 6 1000
176 6 1000
176 1 1000
176 6 1000
176 6 1000
decode(rownum,3,1,6)
如果 rownum = 3 返回 1
rownum = 其他值 返回 6
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14181270/viewspace-1059353/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/14181270/viewspace-1059353/