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
What happens if you add a new index to large table?
What is dbcc updateusage?
What is a mutating table error and how can you get around it?
How to return the top 5 rows from a select query in ms sql server?
How will you go about resolving deadlocks?
What is the advantage of sql server?
How would we use distinct statement? What is its use?
What is an index in sql?
How do you identify a foreign key?
Explain why variables called the most powerful component of ssis?
What is an indexing technique?
How to change the ownership of a schema in ms sql server?
What are trace flags?
List down some advantages of sql stored procedure?
What are the steps you should follow to start sql server in single-user mode?