To find second largest salary in Employee table

Answer Posted / v rajkumar

Select min(salary)FROM emp WHERE salary IN (SELECT distinct
TOP 2 salary FROM emp ORDER BY salary desc)
OR
Select top 1 salary from (select distinct top 2 salary from
emp order by salary desc) emp order by salary

OR
select max(salary) from emp where salary <(select max
(salary) from emp)

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?

569


Benefits of Stored Procedures?

563


What is the filtered index?

559


What is the security principal at the database level that represents your session?

538


How to provide values to user defined function parameters?

553






What are drillthrough reports?

102


What is 1nf normalization form?

593


what is a default tcp/ip socket assigned for sql server? : Sql server database administration

530


What is a data source file?

495


When is update_statistics command used?

581


What are subqueries in sql server? Explain its properties.

540


Can you explain about buffer cash and log cache in sql server?

498


Explain in details security in SQL azure?

97


What is a group function explain with an example?

520


How to create database with physical files specified in ms sql server?

538