本文主要是介绍SQL 单表多条记录分组查询分页代码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
SQL表结构如下图:
SQL 分页语句:
SELECT TOP 5 *,(select count(*) inum from
(select distinct AreaID,AreaTypeID,lifeYear,[State],RelatedID from MonitorBaseEnterInfo where 1=1) i ) as CountNum FROM (SELECT ROW_NUMBER() OVER ( order by lifeYear desc) AS RowNumber,* FROM (select distinct AreaID,AreaTypeID,lifeYear,[State],RelatedID from MonitorBaseEnterInfo where 1=1 ) mm ) A WHERE RowNumber > 5 *(1-1)
查询第一页和第二页如下图:
这篇关于SQL 单表多条记录分组查询分页代码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!