sql分页查询语句 不加desc可以按升序排序并分页 我需要按照时间倒序 加上desc 怎么数据都不变 我是sql2008
这个分页语句SELECTTOP5*FROMWorkDailywhere(guidnotin(SELECTTOP15guidFROMWorkDailyorderbyguid...
这个分页语句
SELECT TOP 5 *
FROM WorkDaily where (guid not in
( SELECT TOP 15 guid FROM WorkDaily order by guid asc))
AND isdelete =0 AND CreateById=85 order by guid desc 展开
SELECT TOP 5 *
FROM WorkDaily where (guid not in
( SELECT TOP 15 guid FROM WorkDaily order by guid asc))
AND isdelete =0 AND CreateById=85 order by guid desc 展开
2个回答
展开全部
时间字段名是什么?看你的SQL语句里好像没有定义时间的排序。
假设时间字段是addtime,那可以这么写:
SELECT TOP 5 *
FROM WorkDaily where (guid not in
( SELECT TOP 15 guid FROM WorkDaily order by guid asc))
AND isdelete =0 AND CreateById=85 order by guid desc,addtime desc
假设时间字段是addtime,那可以这么写:
SELECT TOP 5 *
FROM WorkDaily where (guid not in
( SELECT TOP 15 guid FROM WorkDaily order by guid asc))
AND isdelete =0 AND CreateById=85 order by guid desc,addtime desc
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select top 5 * from RawMaterial where AddTime in (
( select AddTime from
(select ROW_NUMBER() OVER (ORDER BY AddTime desc) AS pos,AddTime from RawMaterial) as T where T.pos > @pageSize* ( @pageIndex- 1 ) AND T.pos <=@pageSize * @pageIndex))
order by AddTime desc
记得给分哦
( select AddTime from
(select ROW_NUMBER() OVER (ORDER BY AddTime desc) AS pos,AddTime from RawMaterial) as T where T.pos > @pageSize* ( @pageIndex- 1 ) AND T.pos <=@pageSize * @pageIndex))
order by AddTime desc
记得给分哦
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询