Friday, May 18, 2018

How do you find 2nd max salary from emp table?

Problem statement: how do you find 2nd maximum salary from employee table?

id | name | salary

01  ram      2000
02  rani      3000
03  lata       1500
04  mary    1700

[1] SELECT MAX(salary) FROM EMPLOYEE; 

//output (return): 3000

[2] SELECT MAX(salary) FROM EMPLOYEE where salary < (SELECT MAX(salary) FROM Employee); 

//output (return) - 2000 that is 2nd highest salary

No comments:

Post a Comment

Blueprint for self-improvement

To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...