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

mysql

Solution

If it's a basic query, then just use LIMIT:

-- get the 4th highest salary
SELECT salary FROM tbl_salary
ORDER BY salary DESC
LIMIT 3,1

Problem

Is there a command akin to: `2nd highest salary from tbl_salary` or `4th highest salary from tbl_salary` ? I've seen: ``` select salary from tbl_salary t where &n = ( select count(salary) from( select distinct salary from tbl_salary )where t.salary<=salary ); ``` How does this it works? Are there other simple ways to get result?

Original source

Related problems