simple solution using cursor and loop
\nCREATE FUNCTION getNthHighestSalary(N IN NUMBER) RETURN NUMBER IS\nresult NUMBER;\nx Employee.salary%TYPE;\nCURSOR cur IS SELECT DISTINCT(salary) FROM Employe
```\nCREATE FUNCTION getNthHighestSalary(N IN NUMBER) RETURN NUMBER IS\nresult NUMBER;\nx Employee.salary%TYPE;\nCURSOR cur IS SELECT DISTINCT(salary) FROM Employee ORDER BY salary DESC;\nBEGIN\n    OPEN cur;\n    LOOP\n        FETCH cur INTO x;\n        EXIT WHEN cur%ROWCOUNT>=N OR cur%NOTFOUND;\n    END LOOP;\n    IF cur%ROWCOUNT=N THEN\n        RETURN x;\n    END IF;\n    CLOSE cur;\n    RETURN NULL;\nEND;\n```
['Oracle']