sql server 分页/最近查询

来源:互联网 发布:淘宝客怎么收费? 编辑:程序博客网 时间:2024/04/28 09:32

sql server 分页/最近查询 (最近3天,0到500条记录,时间和idd倒序)

SELECT t2.rn, t1.* FROM dtcontent AS t1 , (SELECT TOP 500 row_number() OVER (ORDER BY DisplayTime DESC, idd DESC) rn, idd FROM dtcontent where ClassID IN ('C3863', 'C3869', 'C3870', 'C3876') and DATEDIFF(dd,DisplayTime,getdate())<3 and DATEDIFF(dd,DisplayTime,getdate())>= 0) t2 WHERE t1.idd = t2.idd AND t2.rn > 0 ORDER BY t2.rn ASC


0 0
原创粉丝点击