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

后端 未结 30 2549
执笔经年
执笔经年 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:44

    Contrary to what some of the answers claim, the SQL standard is not silent regarding this subject.

    Since SQL:2003, you have been able to use "window functions" to skip rows and limit result sets.

    And in SQL:2008, a slightly simpler approach had been added, using
    OFFSET skip ROWS FETCH FIRST n ROWS ONLY

    Personally, I don't think that SQL:2008's addition was really needed, so if I were ISO, I would have kept it out of an already rather large standard.

提交回复
热议问题