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)
查询第一页和第二页如下图: