Question - Can you get the nth highest salary in Structured Query Language?
Answer -
Here’s how we can get the nth highest salary in SQL SERVER by utilizing the TOP keyword:
SELECT TOP 1 salary FROM ( SELECT DISTINCT TOP N salary FROM #Employee ORDER BY salary DESC ) AS temp ORDER BY salary
To get the nth highest salary in MYSQL, we can use the LIMIT keyword. Here’s the solution:
SELECT salary FROM Employee ORDER BY salary DESC LIMIT N-1, 1