1.先分页获取数据,然后再查询一遍数据库获取到总数量
2.使用count(1) over()获取总记录数量
SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY Id DESC) rn, COUNT(1) OVER() AS TotalCount, Id FROM dbo.T_User )a WHERE a.rn BETWEEN 1 AND 5
1.先分页获取数据,然后再查询一遍数据库获取到总数量
2.使用count(1) over()获取总记录数量
SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY Id DESC) rn, COUNT(1) OVER() AS TotalCount, Id FROM dbo.T_User )a WHERE a.rn BETWEEN 1 AND 5