Showing posts with label SQL queries. Show all posts
Showing posts with label SQL queries. Show all posts

SQL query to finf employees details for second maximum salary

Select * from emp where sal= (select max(sal) from emp where sal<(select max(sal) form emp))

The above query returns all the details of the employee whose salary is second highest.

(select max(sal) from emp where sal<(select max(sal) form emp)) will return the second max salary of an employee.

More : [1]