SQL SERVER取第几行到第几行的方法(包括2000和2005+)

 我来答
东子hnZ
2012-10-21 · 超过76用户采纳过TA的回答
知道答主
回答量:181
采纳率:100%
帮助的人:76.7万
展开全部
--SQL SERVER 2000 取第几行到第几行的方法--(第一种方法) 效率最差select top 5 * from customers where CustomerID not in (select top 5 CustomerID from customers) --(第二种方法) 效率最好, 这里先执行的是Order by 然后才执行Topselect b.* from ( select top 5 a.* from ( select top 10 * from customers order by CustomerID asc ) a order by a.CustomerID desc ) border by b.CustomerID --(第三种方法) 利用临时表和identity(int,1,1DROP TABLE #tempselect identity(int,1,1) as rowID,* into #temp from customers SELECT * FROM #temp WHERE rowID>5 AND rowID<=10--SQL SERVER 2000 取第几行到第几行的方法 --SQL SERVER 2005+ 取第几行到第几行的方法SELECT b.* FROM (SELECT ROW_NUMBER() OVER(ORDER BY c.customerid) rowIndex,* FROM Customers c) bWHERE b.rowIndex>5 AND b.rowindex<=10--SQL SERVER 2005+ 取第几行到第几行的方法
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式