How to find 3rd Max salary in SQL

Select first_name,last_name,salary from employees order by salary desc;



SELECT first_name,last_name,salary from employees e1 
where 3 =(Select COUNT(DISTINCT salary) from employees e2 where e1.salary <e2.salary);

Output:


Leave a Reply

Your email address will not be published. Required fields are marked *