Sunday, February 13, 2022

Find second and third maximum salary from employee

//Second highest salary

 SELECT name, MAX(salary) AS salary FROM employee WHERE salary <> (SELECT MAX(salary) FROM employee);

//Third highest salary

SELECT name, MAX(salary) AS salary FROM employee WHERE salary < (SELECT MAX(salary) FROM employee WHERE salary < (SELECT MAX(salary)FROM employee)); 

No comments:

Post a Comment

Abstract factory pattern

When single task can be done by multiple groups/family of objects and decision is taken at the runtime.