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

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...