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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define full outer join?

522


Explain “not null constraint” in sql server?

526


What is the purpose of a table?

524


What is trigger in salesforce?

499


Why you need indexing? Where that is stored and what you mean by schema object? For what purpose we are using view?

496






How do I find the sql server database version?

532


After creating the cube, if we added a new column to the oltp table then how you add this new attribute to the cube? : sql server analysis services, ssas

572


which backup strategy you are following at ur company

1732


Can we run Reporting Services with SQL Server express edition, which is a free version of SQL Server?

78


Explain can you implement data mining in ssrs?

106


List the data types available in mssql?

530


Explain the difference between control flow and data flow?

529


What is advantage data architect?

511


What is the difference between mysql and sql server?

473


Explain what stored procedure sp_replcounters is used for? : sql server replication

1002