Easy solution without window function
Intuition\nSort -> Skip N-1 rows -> Select the Nth row\n\n# Approach\nSort the salaries of employees in descending order and skip the first N - 1 rows using the
# Intuition\nSort -> Skip N-1 rows -> Select the Nth row\n\n# Approach\nSort the salaries of employees in descending order and skip the first N - 1 rows using the OFFSET clause. This effectively discards the salaries of the N - 1 highest-paid employees.\nFinally, fetch the next 1 row using the FETCH NEXT 1 ROWS ONLY clause, which retrieves the salary of the Nth highest-paid employee.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nCREATE FUNCTION getNthHighestSalary(@N INT) RETURNS INT AS\nBEGIN\n    RETURN (\n        /* Write your T-SQL query statement below. */\n          SELECT DISTINCT SALARY FROM Employee ORDER BY Salary DESC\n          OFFSET @N - 1 ROWS\n          FETCH NEXT 1 ROWS ONLY       \n    );\nEND\n```
['MS SQL Server']