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

Hi,

Can anybody please explain me the flow of the below query.
I am not able to understand how this query works.

This query is for finding the Nth highest salary..

SELECT DISTINCT (a.sal)
FROM EMP A
WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B
WHERE a.sal<=b.sal);

If N = 2 then second highest salary will be the o/p.
If N = 3 then third highest salary will be the o/p.
and so on..

Thanks,
Nitin

Answer Posted / nitin

Thank you.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain alias in sql?

997


Why schema is used in sql?

989


Can you load data into multiple tables at once? : aql loader

1025


What are the datatypes available in pl/sql ?

1045


Mention what is the plv (pl/vision) package offers?

1058


What is full join in sql?

940


What is a ddl command?

1011


what is a table called, if it has neither cluster nor non-cluster index? What is it used for? : Sql dba

933


Where are my tempfiles, I don't see them in v$datafile or dba_data_file?

946


how do you know if your mysql server is alive? : Sql dba

1027


What are aggregate and scalar functions?

978


What is substitution variable in pl sql?

981


Can we debug stored procedure?

959


What is the difference between sql and isql*plus?

1009


Can a trigger call a stored procedure?

1004