Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Thursday 8 March 2018

2nd highest salary sql

Here i have posted three methods to find second highest salary of an employee.



select max(salary) from employee where salary not in(select max(salary) from employee)


                                                                     OR



select max(salary) from employee where salary <=(select max(salary) from employee)




                                                                       OR

SELECT salary from(select salary from employee where rownum<=2 order by salary asc )  employee where rownum = 1;


No comments:

Post a Comment