SELECT *
FROM
(
SELECT *,ROW_NUMBER() OVER (ORDER
BY ID asc) AS RowNum
FROM qnfh
) AS T
WHERE T.RowNum> 0 and
T.RowNum<= 10
SELECT *
FROM
(
SELECT *,ROW_NUMBER() OVER (ORDER BY ID
asc) AS RowNum
FROM qnfh
) AS T
WHERE T.RowNum> 10 and
T.RowNum<= 20
取出sql表中第31到40的记录(以自动增长ID为主键)
sql server方案1:
select top 10 * from qnfh where id not in (select top 30
id from qnfh order by id ) order by id
sql server方案2:
select top 10 *
from qnfh where id in (select top 40 id from qnfh order by id) order by id
desc