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
Which table keeps the locking information?
What are the new features of sql server 2008 r2 reporting service?
What xml support does the sql server extend?
Why use sub query in sql server and list out types of sub queries?
When is the use of update_statistics command?
How do we know if any query is retrieving a large amount of data or very little data?
Explain the use of containers in ssis and also their types?
Do you know what is difference between index seek vs. Index scan?
Can group by be used without aggregate functions?
Name few endpoints exposed by ssrs 2012?
What is relationship? What number of sorts of relationship are there?
What is sql server management studio? : sql server management studio
What is the maximum size of sql server database?
Explain “@@rowcount” and “@@error” in sql server?
What are the components of dbms?