文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>SQL SERVER取第几行到第几行的方法(包括2000和2005+)

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

时间:2011-04-16  来源:

 

--SQL SERVER 2000 取第几行到第几行的方法

--(第一种方法) 效率最差

select   top   5   *   from   customers   where   

CustomerID   not   in   (select   top   5   CustomerID   from   customers) 

--(第二种方法)  效率最好

select   b.*   from 

select   top   5   a.*   from   

select   top   10   *   from   customers   order   by   CustomerID   asc 

)   a   order   by   a.CustomerID   desc 

) b

order   by   b.CustomerID    

--(第三种方法) 利用临时表和identity(int,1,1

DROP TABLE #temp

select  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

) b

WHERE b.rowIndex>5 AND b.rowindex<=10

--SQL SERVER 2005+ 取第几行到第几行的方法

排行榜 更多 +
魔兽8m补丁 附使用方法

魔兽8m补丁 附使用方法

行业软件 下载
富甲天下5修改器 v1.0.5.0中文绿色版

富甲天下5修改器 v1.0.5.0中文绿色版

行业软件 下载
造梦西游5小望修改器 v2.2.1中文免费版

造梦西游5小望修改器 v2.2.1中文免费版

行业软件 下载