oracle中怎么先排序然后再从排序后的数据中取前几条
方法是:
select * from (select * from t order by col1) where rownum<10
选取排序后的前N条记录:
1. Sql代码
select top 3 e_name from ptemp.cuishen_temp_20100707 order by id
select top 3 e_name from ptemp.cuishen_temp_20100707 order by id
Sql代码
select top 3 * from ptemp.cuishen_temp_20100707 order by id
select top 3 * from ptemp.cuishen_temp_20100707 order by id
2.分页查询
可以用row_number关键字来进行分页查询,例如:
Sql代码
select * from ptemp.cuishen_temp_20100707 qualify row_number() over(order by id) >= 2 and row_number() over(order by id) <= 5
select * from ptemp.cuishen_temp_20100707 qualify row_number() over(order by id) >= 2 and row_number() over(order by id) <= 5