Answer: Here the main constraint is we should not use the TOP keyword.
The query is
select MAX(Salary) from tbl_Employee
where Salary <> (
select MAX(Salary) from tbl_Employee)
In sub query I am first getting the Maximum salary of Employee Table. Now 7855 will come. In the outer query I am using Where condition to check the salary NOT EQUAL to 7855 and gettting the maximum value in select query. So now the query will be
select MAX(Salary) from tbl_Employee
where Salary <> 7855
The above query gives 7000 which is the second maximum salary
Asked In: GAVS Technology |
Alert Moderator