How To Find Second Max Salary Of Employee
The basic question always asked during interview is how to find second max salary of Employee
Employee_Salary
# Let we consider a table Employee_Salary contains the columns Emp_Id,Emp_Name,Emp_Salary.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## So let we go through Max Salary
* SELECT MAX(Emp_Salary) FROM Employee_Salary here we get the max salary of employee from Employee_Salary table.
///////ouput is 14000
## Now we go through Second Max Salary
* SELECT MAX(Emp_Salary) FROM Employee_Salary where Emp_Salary not in(SELECT MAX(Emp_Salary) FROM Employee_Salary)
///////ouput is 13000
Comments
Post a Comment