SQL 单表多条记录分组查询分页代码

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 单表多条记录分组查询分页代码


SQL 单表多条记录分组查询分页代码


上一篇:【数道云大数据】Hadoop大数据技术有什么市场价值?2019年Hadoop大数据技术7大应用领域


下一篇:直播源码前期该如何运营?