Skip first row in SQL Server 2005?

后端 未结 4 1659
野趣味
野趣味 2021-01-12 13:49

We can select Top 10 or Select Top \'N\' row from SQL Server.

But is there any way to skip first row from the result of top??

I mea

4条回答
  •  悲哀的现实
    2021-01-12 14:44

    You could do something like this:

    SELECT
        *
    FROM (
            SELECT      
                row_number() OVER (ORDER BY ID DESC) AS [rownum],
                *
            FROM
                tbl
    ) T
    WHERE 
        rownum BETWEEN (2) AND (5)
    

    Update:

    Updated to have your values.

    Update 2:

    Corrected error with missing sub query. Thanks to Chris Diver pointing this out.

提交回复
热议问题