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 查出来的结果当成一个临时表 

你可能感兴趣的:(sql server 2005)