3 solutions for Oracle, MySQL and SQL Server
ORACLE\n\n\nCREATE FUNCTION getNthHighestSalary(N IN NUMBER) RETURN NUMBER IS\nresult NUMBER;\nBEGIN\n    SELECT MAX(Salary) INTO result\n    FROM (\n        SE
ORACLE\n\n```\nCREATE FUNCTION getNthHighestSalary(N IN NUMBER) RETURN NUMBER IS\nresult NUMBER;\nBEGIN\n    SELECT MAX(Salary) INTO result\n    FROM (\n        SELECT Salary, DENSE_RANK() OVER(ORDER BY Salary DESC) AS RK\n        FROM Employee\n     ) T\n     WHERE RK = N;\n    \n    RETURN result;\nEND;\n```\n\nMySQL\n\n```\nCREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT\nBEGIN\n  RETURN (\n      SELECT DISTINCT Salary\n      FROM (\n        SELECT \n          Salary,\n          DENSE_RANK() OVER(ORDER BY Salary DESC) AS RK\n        FROM Employee\n            ) T\n      WHERE RK = N\n  );\nEND\n```\n\nSQL Server\n\n```\nCREATE FUNCTION getNthHighestSalary(@N INT) RETURNS INT AS\nBEGIN\n    RETURN (\n        SELECT DISTINCT Salary\n        FROM (\n        SELECT \n          Salary,\n          DENSE_RANK() OVER(ORDER BY Salary DESC) AS RK\n        FROM Employee\n            ) T\n        WHERE RK = @N\n        \n    );\nEND\n```
[]