标签:
数据表中比如有20条数据
读取前5条数据
select top 5 * from 表 order by id desc
读取前5条数据后的5条数据
(就是查询前10条记录,取后面5个)
select top 5 * from 表 where
id not in (select top 5 id from 表)
===================================================================================
SELECT TOP 11 * FROM (
SELECT ROW_NUMBER() OVER (ORDER BY StuID) AS RowNumber, *
FROM StuInfo) t
WHERE RowNumber >= 10
假设StuID是StuInfo表的主键“学号”。先按学号排序,生成行号,再返回行号>=10时的前11条记录,即行号为10~20的11条记录。
=======================================================================
select top 10 * from [table_name] where id in (select top 20 id from [table_name] order by id desc) order by id asc
这样显示出来的就是:从11到20条数据
标签:
原文地址:http://www.cnblogs.com/aiqingqing/p/4347062.html