How to find n'th highest value of a column?

前端 未结 8 1541
不思量自难忘°
不思量自难忘° 2021-02-20 07:56

Is there a command akin to:

  • 2nd highest salary from tbl_salary or

  • 4th highest salary from tbl_salary ?

8条回答
  •  伪装坚强ぢ
    2021-02-20 08:39

    I'm sure there is a better way to do this, but:

    SELECT salary FROM tbl_salary ORDER BY salary DESC LIMIT n,1

    Where n is the position you want - 1 (i.e. to get the second highest salary it would be LIMIT 1,1)

提交回复
热议问题