MSSQL-SQL SERVER 分页原理

项目中用到的, 用心琢磨一下此SQL语句即可:

SELECT TOP $row * FROM (
        SELECT ROW_NUMBER() OVER (ORDER BY [ID] desc) AS RowNumber,
             [PFLoginCount],[PFUserLoginCout],[ADLoginCout],[ADUserLoginCout],[UserDaySum]
             ,[RecordTime]=CONVERT(VARCHAR(19),[RecordTime],120)
              FROM [TkDotaDB].[dbo].[DOTA_UserLoginCount]
        ) A WHERE RowNumber >  + ($page - 1) * $row ORDER BY RowNumber

posted on 2013-10-12 16:21  John_ABC  阅读(260)  评论(0编辑  收藏  举报

导航