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

what is a tablespace? : Sql dba

1046


How to display the records between two range in Oracle SQL Plus?

1138


What does trigger mean in psychology?

958


Why is stored procedure faster than query?

946


Why do we use procedures?

949


how can we find the number of rows in a table using mysql? : Sql dba

1073


what are integrity rules?

1020


how can we take a backup of a mysql table and how can we restore it. ? : Sql dba

965


What is java sql connection?

1037


What are the disadvantages of file system?

1251


What is flag in sql?

1026


What is a temp table?

1017


Explain the difference between cursor declared in procedures and cursors declared in the package specification?

1132


What is user defined functions?

959


How to order siblings in oracle hierarchy queries?

1032