How to get nᵗʰ highest value using plain SQL

前端 未结 8 1077
孤城傲影
孤城傲影 2021-01-24 23:42

What is the simplest way to get the nth highest value from a result set using plain SQL?

The result set would be huge, thus need to consider performance too.

8条回答
  •  闹比i
    闹比i (楼主)
    2021-01-25 00:20

    In Oracle:

    SELECT * FROM (
      SELECT col1, ROW_NUMBER()OVER(ORDER BY col1) rnum_col1 FROM table1
    ) WHERE rnum_col1 = 10;
    

提交回复
热议问题