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...

find out the third highest salary?

Answer Posted / rajdevar

Guys
i have executed this query in sql plus.This is correct

Select * from EMP_USER A where n-1 = (select count
(distinct (sal)) from EMP_USER B where A.sal<B.sal)

where n=3

reason for using n-1 is below:

1.We are using correlated sub query.so sal value from each
row in outer query(EMP_USER A) is compared with sal of all
the rows in EMP_USER B

eg:
ENAME SAL
----- -----
SMITH 800
KING 5000
FORD 3000

here third highest is 800.so when executing this 800 from
outer query is compared with 800,5000,3000 in inner query
which returns a count(distinct(sal) = 2

if you use n instead of n-1 you get a empty result.

Let me know if this is correct

Is This Answer Correct ?    13 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between inner join vs where ?

977


How to unlock the sample user account in oracle?

916


How to rename an index?

995


Can we use oracle pl/sql block in core java? if so how? pls get back to me .....

2899


How to name query output columns in oracle?

1130


How to delete multiple rows from a table in oracle?

1003


How to define an external table with a text file?

1019


Is oracle a programming language?

935


Is there an oracle sql query that aggregates multiple rows into one row?

930


How to define default values for formal parameters?

982


How can you tell how much space is left on a given file system and how much space each of the file systems subdirectories take-up?

2772


How do I manually create a database in oracle?

955


How to do paging with oracle?

948


How to start an oracle instance?

951


What are the arithmetic operations?

1024