SQL Server 2005 中 ROW_NUMBER()的用法

SELECT * FROM
(SELECT ROW_NUMBER() OVER(ORDER BY RecordId) AS RowID,* FROM BaseUser

) as table1

WHERE RowID BETWEEN 20 AND 30

 -- RowID 将SELECT ROW_NUMBER() OVER(ORDER BY RecordId) 查出的结果取个别名,用于取结果记录的条件[即: RowID BETWEEN 20 AND 30]

--table1 相当于 SELECT ROW_NUMBER() OVER(ORDER BY RecordId) AS RowID,* FROM BaseUser 查出来的结果当成一个临时表 

posted on 2010-01-29 11:40  bicabo  阅读(340)  评论(0编辑  收藏  举报

导航