sqlserver的分页语句


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

sqlserver的分页语句,布布扣,bubuko.com

sqlserver的分页语句

上一篇:php 操作mongodb


下一篇:PS快速修复曝光不足照片的两种方法