oracle中怎么先排序然后再从排序后的数据中取前几条
答案:2 悬赏:40 手机版
解决时间 2021-11-23 19:47
- 提问者网友:鐵馬踏冰河
- 2021-11-23 06:42
oracle中怎么先排序然后再从排序后的数据中取前几条
最佳答案
- 五星知识达人网友:一叶十三刺
- 2021-11-23 07:50
方法是:
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
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
全部回答
- 1楼网友:不甚了了
- 2021-11-23 09:25
select * from (select * from t order by col1) where rownum<10;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯