Oracle中rownum与order by的执行顺序 正确的写法应该是:先order by,先包一层查询,再赋rownum值
原文链接:https://blog.csdn.net/u013456370/article/details/122366975
- select id,createdate,finvoutype from nc_ext_fa_ls_pz_hzdoc doc
- where doc.company = '3000004' and doc.finvoutype = 'YUFZXD'
- and doc.gxmlflag = '20220107'
- and rownum <=10 order by doc.createdate
第一种方法:id:6321 没取值出来;
- select id from (
- select id from nc_ext_fa_ls_pz_hzdoc doc
- where doc.company = '3000004' and doc.finvoutype = 'YUFZXD'
- and doc.gxmlflag = '20220107'
- order by doc.createdate) where rownum <=10
第二种方法: id:6321 能取值出来;
执行顺序
Oracle会先设置行的rownum,再进行order by
执行顺序:rownum > order by
正确的写法应该是:先order by,先包一层查询,再赋rownum值
标签:doc,再赋,order,rownum,id,先包 From: https://www.cnblogs.com/sunny3158/p/17547531.html