return 3rd highest salary from employee table in sql code example
Example 1: third highest salary in sql
SELECT ename,sal from Employee e1 where
N-1 = (SELECT COUNT(DISTINCT sal)from Employee e2 where e2.sal > e1.sal)
Example 2: third highest salary in sql
SELECT * FROM Employee WHERE sal =
(
SELECT MIN(sal) FROM Employee
WHERE sal IN (
SELECT DISTINCT TOP N
sal FROM Employee
ORDER BY sal DESC
)
)