Equivalent of LIMIT and OFFSET for SQL Server?

前端 未结 16 2137
天命终不由人
天命终不由人 2020-11-22 06:07

In PostgreSQL there is the Limit and Offset keywords which will allow very easy pagination of result sets.

What is the equivalent syntax f

16条回答
  •  萌比男神i
    2020-11-22 06:39

    The closest I could make is

    select * FROM( SELECT *, ROW_NUMBER() over (ORDER BY ID ) as ct from [db].[dbo].[table] ) sub where ct > fromNumber  and ct <= toNumber
    

    Which I guess similar to select * from [db].[dbo].[table] LIMIT 0, 10

提交回复
热议问题