码迷,mamicode.com
首页 > 数据库 > 详细

oracle行号排序问题

时间:2014-12-03 09:16:14      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:style   blog   ar   color   sp   on   数据   div   问题   

1、创建一个student,并且插入数据

create table student(name varchar(12),age int)

insert into student values(‘z1‘,‘1‘);
insert into student values(‘z2‘,‘6‘);
insert into student values(‘z3‘,‘2‘);
insert into student values(‘z4‘,‘3‘);
insert into student values(‘z5‘,‘7‘);
commit;

2、直接按照age进行排序显示行号:

select * from(select rownum rw,t.* from student t order by t.age asc)

 

3另一种查询,能够很好地查找:

select row_number() over( order by t.age asc) rw,t.* from student t

 

oracle行号排序问题

标签:style   blog   ar   color   sp   on   数据   div   问题   

原文地址:http://www.cnblogs.com/dragkiss/p/4137180.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!