MySQL | Using limit and offset: Faster than 100%
Order the records by salary in desc order\nLimit results to 1 row\nOffset N-1. (Skip all the rows before the intended row)\n\n\nCREATE FUNCTION getNthHighestSal
Order the records by salary in desc order\nLimit results to 1 row\nOffset N-1. (Skip all the rows before the intended row)\n\n```\nCREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT\nBEGIN\nDECLARE M INT DEFAULT 0;\nSET M = N-1;\n  RETURN (\n      # Write your MySQL query statement below.\n      select (select distinct salary from Employee order by salary desc limit 1 offset M)\n  );\nEND\n```
[]