Today I will share how to find second highest salary using SQL query of a employee table. So, first of all we can find highest salary using max(salary), here max is built in operator in SQL to find the maximum value.
As it is said to find second highest so after getting highest I need to get the smaller of that salary and conditionally all are smaller so among them I need the highest and that is the second highest.
Finally I need a sub query to find max salary and condition will bee less than that. Here is the SQL query code.
SELECT MAX(SALARY) FROM Employee WHERE SALARY < (SELECT MAX(SALARY) FROM Employee
So using this you can also find the second highest salary.
0 Comments