How to select a row based on its row number?

前端 未结 6 1487
猫巷女王i
猫巷女王i 2020-12-28 18:12

I\'m working on a small project in which I\'ll need to select a record from a temporary table based on the actual row number of the record.

How can I select a record

6条回答
  •  猫巷女王i
    2020-12-28 18:35

    If using SQL Server 2012 you can now use offset/fetch:

    declare @rowIndexToFetch int
    set @rowIndexToFetch = 0
    
    select
        * 
    from 
        dbo.EntityA ea
    order by
        ea.Id
    offset @rowIndexToFetch rows
    fetch next 1 rows only
    

提交回复
热议问题