Row Offset in SQL Server

后端 未结 16 2639
醉酒成梦
醉酒成梦 2020-11-22 05:53

Is there any way in SQL Server to get the results starting at a given offset? For example, in another type of SQL database, it\'s possible to do:

SELECT * FR         


        
16条回答
  •  猫巷女王i
    2020-11-22 06:23

    You can use ROW_NUMBER() function to get what you want:

    SELECT *
    FROM (SELECT ROW_NUMBER() OVER(ORDER BY id) RowNr, id FROM tbl) t
    WHERE RowNr BETWEEN 10 AND 20
    

提交回复
热议问题