oracle 按时间排序,然后进行分页的sql改怎么写?急~~~ 表中有(时间字段)

 我来答
lin67152
2013-05-23 · TA获得超过310个赞
知道小有建树答主
回答量:122
采纳率:100%
帮助的人:35.3万
展开全部
SELECT t.字段名 FROM (
SELECT 字段(可以是多表关联的字段) ,
row_number() over(order by 时间字段 desc) r
FROM 表名 where 过滤条件 ) t
where t.r <= (每页显示条数*要查询的页) and t.r > (每页显示条数*(要查询的页-1))
有疑问可以再问
望采纳
更多追问追答
追问
SELECT * FROM ( SELECT row_.*, rownum rownum_ FROM (select repairyardcode,repairyardname,comcode,channelcode,cooname,cooaddress,coozipcode,coocontact,coophone,coofax,picname,pictel,picphone,picemail,remark,flag,acomcode,acomname,repaircode,modelname,longitude,latitude,operatedate from prpdrepairyard   where 1=1   order by operatedate desc) row_ WHERE rownum  0
追答
你这写的是什么意思,这个没有分页吧,而且你不要用*来查询,会影响查询性能的
匿名用户
2013-05-23
展开全部
SELECT
*
FROM
(
select
rownum AS NO,
表.*
from

order by
表.时间字段
) subQuery
WHERE
NO between 开始行 AND 结束行;
追问
SELECT * FROM ( SELECT row_.*, rownum rownum_ FROM (select repairyardcode,repairyardname,comcode,channelcode,cooname,cooaddress,coozipcode,coocontact,coophone,coofax,picname,pictel,picphone,picemail,remark,flag,acomcode,acomname,repaircode,modelname,longitude,latitude,operatedate from prpdrepairyard   where 1=1   order by operatedate desc) row_ WHERE rownum  0??
追答
SELECT
*
FROM
(
select
rownum rownum_
repairyardcode,repairyardname,comcode,
channelcode,cooname,cooaddress,
coozipcode,coocontact,coophone,
coofax,picname,pictel,picphone,
picemail,remark,flag,
acomcode,acomname,repaircode,
modelname,longitude,latitude,
operatedate
from prpdrepairyard
where 1=1
order by operatedate desc
) row_
WHERE
rownum_ >= 1 AND rownum_ <= 10
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式