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
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