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

Is it possible to run multiple publications and different type of publications from the same distribution database? : sql server replication

583


How to use group functions in the select clause in ms sql server?

548


Which language rdl files made of?

100


Do you know what is normalization of database? What are its benefits?

568


Explain the advantages of merge replication?

522






I create a separate index on each column of a table. What are the advantages and disadvantages of this approach? : Sql server database administration

596


Can you explain powershell included in sql server 2008?

516


How to use values from other tables in update statements in ms sql server?

567


Write a SQL queries on Self Join and Inner Join.

623


what stored procedure would you use to view lock information? : Sql server administration

591


How to get a list of columns using the "sys.columns" view in ms sql server?

568


What are the 7 disadvantages to a manual system?

517


You want to use bids to deploy a report to a different server than the one you chose in the report wizard. How can you change the server url?

112


What is RMS migrations?

1713


List layers of abstraction microsoft architectured to provide relational db through cloud platform ?

163