I'm trying to get second heights salary but not able to fetch record from database

Advertisements

SELECT MAX(SALARY) FROM Employee WHERE SALARY >= (SELECT MAX(SALARY) FROM Employee);

Above is my SQL query, I try multiple time how to fetch the data of second heights salary.
But getting invalid response of query.

I’m expecting show the second heights salary from the 10k user. Those who have second heights salary. Please help to solve that. Its my task from interview.

>Solution :

SELECT MAX(SALARY) FROM Employee WHERE SALARY < (SELECT MAX(SALARY) FROM Employee);

replace your query

Leave a ReplyCancel reply