Sunday, September 27, 2020

Find out second highest salary in Employee Table

 -- Second highest salary

SELECT MAX(salary) FROM Employee WHERE Salary NOT IN ( SELECT Max(Salary) FROM Employee);


This solution uses subquery to first exclude the maximum salary from the data set and then again finds maximum salary, which is effectively the second maximum salary from the Employee table.

No comments:

Post a Comment