How to select the nth row in a SQL database table?

后端 未结 30 2885
执笔经年
执笔经年 2020-11-22 06:06

I\'m interested in learning some (ideally) database agnostic ways of selecting the nth row from a database table. It would also be interesting to see how this can b

30条回答
  •  不要未来只要你来
    2020-11-22 06:45

    unbelievable that you can find a SQL engine executing this one ...

    WITH sentence AS
    (SELECT 
        stuff,
        row = ROW_NUMBER() OVER (ORDER BY Id)
    FROM 
        SentenceType
        )
    SELECT
        sen.stuff
    FROM sentence sen
    WHERE sen.row = (ABS(CHECKSUM(NEWID())) % 100) + 1
    

提交回复
热议问题