本站不再更新,欢迎光临 java开发技术网
随笔-230  评论-230  文章-8  trackbacks-0
用rownum实现大于、小于逻辑(返回rownum在4—10之间的数据)(minus操作,速度会受影响) 
select rownum,month,sell from sale where rownum<10 
minus 
select rownum,month,sell from sale where rownum<5; 

返回第5—9条纪录,按月份排序 
select * from (select rownum row_id ,month,sell
from (select month,sell from sale group by month,sell)) 
where row_id between 5 and 9;

posted on 2006-04-03 15:55 有猫相伴的日子 阅读(646) 评论(4)  编辑  收藏 所属分类: pl/sql

评论:
# re: 使用rownum实现分页 2006-05-15 16:16 | 有猫相伴的日子
查询分页

select * from (select a.* , rownum brow from (select * from service_info)a where rownum<40 ) where brow>=20;  回复  更多评论
  
# re: 使用rownum实现分页 2006-05-15 16:26 | 有猫相伴的日子
select * from (select a.*,rownum row_id from service_info a )where row_id between 21 and 40;  回复  更多评论
  
# re: 使用rownum实现分页 2006-11-16 16:39 | 一笑而过
其实经过执行计划的检验:
一楼的用的oracle常规分页,而这种方式其实是最有效的,所以oracle也推荐这样使用  回复  更多评论
  
# re: 使用rownum实现分页[未登录] 2009-05-23 12:40 | hhh
@有猫相伴的日子
不错SQL语音精简了,哈... 高手  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
本站不再更新,欢迎光临 java开发技术网