How to find the second largest salary in the emp database and
also How to find 3rd,4th and so on ........ in the emp database

plz mail the answer @ mak2786@gmail.com

Answer Posted / s n yagneswara babu

TO FIND THE SECOND HIGHEST SAL IN EMP TABLE

select max(sal) from emp where sal not in(select max(sal)
from emp)

TO FIND THE 3RD HIGHEST SAL IN EMP TABLE

select max(sal) from emp where sal not in(select distinct
top 2 sal from emp order by sal desc)

TO FIND THE Nth HIGHEST SAL IN EMP TABLE

select max(sal) from emp where sal not in(select distinct
top N-1 sal from emp order by sal desc)

yagneswara babu
yagnesh_sn@yahoo.co.in

Is This Answer Correct ?    39 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the steps to follow to configure SQL*Net?

772


What is change data capture (cdc) feature?

786


Why we need to use secondry database file? though, we can do same work using primary database file also.

6201


Do you know how to store and query spatial data?

780


Explain what is dbcc?

779






what is sql server? : Sql server database administration

696


What is default constraint in ms sql server?

712


Using the customer, and order table in northwind database, please write a query to produce xml?

849


What are sql server functions?

678


What is precedence constraint?

715


How does using a separate hard drive for several database objects improves performance right away?

699


Do you know exporting and importing utility?

696


Explain different types of collation sensitivity?

701


What type of Index will get created after executing the above statement?

842


What are the advantages of passing name-value pairs as parameters?

832