Query:-
SELECT Emp_Name,Emp_Salary
FROM Employee e1
WHERE
2 = (SELECT COUNT(DISTINCT (e2.Emp_Salary))FROM Employee e2 WHERE e2.Emp_Salary >= e1.Emp_Salary)
The above employee table contains two same records as second highest salary so the result set will look like below output table.
Output:-
Emp_Name Emp_Salary
Sham 15000
SELECT Emp_Name,Emp_Salary
FROM Employee e1
WHERE
2 = (SELECT COUNT(DISTINCT (e2.Emp_Salary))FROM Employee e2 WHERE e2.Emp_Salary >= e1.Emp_Salary)
The above employee table contains two same records as second highest salary so the result set will look like below output table.
Output:-
Emp_Name Emp_Salary
Sham 15000
Comments
Post a Comment