首页 > 代码库 > row_number() over 两表连接分页SQL
row_number() over 两表连接分页SQL
--总条数 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 两表连接分页SQL
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。