Two easy sollutions
Upvote if this finds helpful to you!\n\n 1.\n\nCREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT\nBEGIN\nDECLARE M INT;\nSET M=N-1;\n  RETURN (\n      # Wr
**Upvote if this finds helpful to you!**\n\n 1.\n```\nCREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT\nBEGIN\nDECLARE M INT;\nSET M=N-1;\n  RETURN (\n      # Write your MySQL query statement below.\n       select distinct salary from Employee order by salary desc limit 1 offset M\n);\nEND\n```\n2.\n```\nCREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT\nBEGIN\n  RETURN (\n      # Write your MySQL query statement below.\nselect  case \n           when (select count(distinct salary) from Employee)>N-1 then salary\n           else null\n        end\nfrom (\n       select salary from Employee\n       group by salary\n       order by salary desc\n       limit N\n)  \nas sub\norder by salary asc \nlimit 1 \n);\nEND\n\n```
[]