如何用ROW_NUMBER()分页时获取总记录数而计算出总页数?
展开全部
1、每条查询记录的RecordCount就是总数量,放在第一个字段:
SELECT (select count(*) as RecordCount from TableName), * FROM (SELECT ROW_NUMBER() OVER (ORDER BY [ID]) AS [ROW_NUMBER], * FROM TableName AS [t0]) AS [t1] WHERE [t1].[ROW_NUMBER] BETWEEN 0 AND 30
2、存储过程你可以参考一下网上的。大至如下:
@RecordCount int output
Select RecordCount=select count(*) from TableName where 1=1
剩下就是你选择的编程语言怎么获得RecordCount的问题了。
SELECT (select count(*) as RecordCount from TableName), * FROM (SELECT ROW_NUMBER() OVER (ORDER BY [ID]) AS [ROW_NUMBER], * FROM TableName AS [t0]) AS [t1] WHERE [t1].[ROW_NUMBER] BETWEEN 0 AND 30
2、存储过程你可以参考一下网上的。大至如下:
@RecordCount int output
Select RecordCount=select count(*) from TableName where 1=1
剩下就是你选择的编程语言怎么获得RecordCount的问题了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询