标签:row_number over 两表连接分页 row_number over 不排序
--总条数 SELECT COUNT(1) FROM dbo.osaleh INNER JOIN dbo.osaled ON dbo.osaleh.osaleh_osalehID=dbo.osaled.osaled_osalehID WHERE --两表连接分页 SELECT * FROM( SELECT ROW_NUMBER() OVER ( ORDER BY osaleh_osalehID DESC ) AS rownum, dbo.osaleh.osaleh_osalehID, dbo.osaleh.osaleh_custname, dbo.osaleh.osaleh_tel, dbo.osaleh.osaleh_Name, dbo.osaleh.osaleh_userID, (SELECT User_LastName FROM dbo.Users (NOLOCK) WHERE User_UserId=dbo.osaleh.osaleh_userID) AS SalesManName, dbo.osaleh.osaleh_mkdate, dbo.osaled.osaled_oactvhID FROM dbo.osaleh INNER JOIN dbo.osaled ON dbo.osaleh.osaleh_osalehID=dbo.osaled.osaled_osalehID WHERE dbo.osaled.osaled_oactvhID=2 ) AS tb WHERE rownum BETWEEN( (1 - 1) *5+1) AND ( 1 * 5 ) --如果不排序 SELECT * FROM( SELECT ROW_NUMBER() OVER ( ORDER BY (SELECT 0) ) AS rownum, dbo.osaleh.osaleh_osalehID, dbo.osaleh.osaleh_custname, dbo.osaleh.osaleh_tel, dbo.osaleh.osaleh_Name, dbo.osaleh.osaleh_userID, (SELECT User_LastName FROM dbo.Users (NOLOCK) WHERE User_UserId=dbo.osaleh.osaleh_userID) AS SalesManName, dbo.osaleh.osaleh_mkdate, dbo.osaled.osaled_oactvhID FROM dbo.osaleh INNER JOIN dbo.osaled ON dbo.osaleh.osaleh_osalehID=dbo.osaled.osaled_osalehID WHERE dbo.osaled.osaled_oactvhID=2 ) AS tb WHERE rownum BETWEEN( (1 - 1) *5+1) AND ( 1 * 5 )
标签:row_number over 两表连接分页 row_number over 不排序
原文地址:http://blog.csdn.net/chinaplan/article/details/39207711