Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Explain “@@rowcount” and “@@error” in sql server?

1095


What are key constraints?

977


How to insert new line characters into strings?

995


Can you leave a union at any time?

1064


How to download and install microsoft .net framework version 2.0?

1140


Does dbcc checkdb requires db to be in single_user mode? : sql server database administration

984


Do you know what is xpath?

1092


What is not null constraint?

1130


Suggest a method of joining two tables.

1160


What are some examples of schemas?

982


What are the differences between INNER JOIN, LEFT JOIN and RIGHT JOIN in SQL Server?

1139


Please explain go command in sql server?

1059


What is the command used to check locks in microsoft sql server?

1045


Why I am getting this error when renaming a database in ms sql server?

1059


What is isolation levels?

1034