oracle 按时间排序,然后进行分页的sql改怎么写?急~~~ 表中有(时间字段)
2个回答
展开全部
SELECT t.字段名 FROM (
SELECT 字段(可以是多表关联的字段) ,
row_number() over(order by 时间字段 desc) r
FROM 表名 where 过滤条件 ) t
where t.r <= (每页显示条数*要查询的页) and t.r > (每页显示条数*(要查询的页-1))
有疑问可以再问
望采纳
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 结束行;
*
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询