`
lluorongsheng
  • 浏览: 33917 次
  • 性别: Icon_minigender_1
  • 来自: 广州
文章分类
社区版块
存档分类
最新评论

oracle中用rownum分页并排序的SQL语句

阅读更多
1.Oracle的分页查询语句基本.分页格式
	select * from
	(
	   select a.*, rownum rn
	   from (select * from table_name) a
           --rownum表示拿到数据库的总条数--
	   where rownum <= 40
	)
        --rn表示从第21条记录数开始读取--
	where rn >= 21

展示的在查询的第二层通过ROWNUM <= 40来控制最大值,在查询的最外层控制最小值

2.在查询的最外层控制分页的最小值和最大值
select * from
	(
	   select a.*, rownum rn
	   from (select * from table_name) a
	)
	where rn between 21 and 40



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics