先對結果集排序然后做update、delete操作


--先排序然后刪除第n條數據
delete from scott.emp
 where empno in (select empno
                   from (select *
                           from scott.emp
                          where comm is null
                            and rownum < 2
                          order by hiredate desc));

--先排序然后更新第n條數據
update scott.emp                                  
   set comm = 123                                 
 where empno in (select empno                     
                   from (select empno             
                           from scott.emp         
                          where rownum < 2        
                            and comm is null      
                          order by hiredate asc));


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM