Let's start from a Normal query if you have to find max salary from that table that would be .
select MAX(Salary) from Employee;
And now if we have to find sec highest salary from the table , see the query :
select MAX(Salary) from Employee where Salary NOT IN (select MAX(Salary) from Employee);
And query for nth highest salary :
FROM Employee Emp1
WHERE (N-1) = ( SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Salary > Emp1.Salary)
After seeing this query you may be get confused because of Emp1 and Emp2 , Let me tell you about it.
Emp1 and Emp2 are nothing but alias of Employee table. I hope you understood.