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

how many groups of data types? : Sql dba

1031


What is date functions?

1036


What are the differences between in and exists clause?

1114


How do you delete duplicates in sql query using rowid?

950


Can I call a procedure inside a function?

1016


what is self-join? : Sql dba

1170


What are the disadvantages of file system?

1271


Can we use pl sql in mysql?

1019


Why we use cross join?

959


Can I learn sql in a week?

1083


Is ms sql traffic encrypted?

929


What is trigger in pl sql?

1005


What is the need of a partition key?

989


what is the difference between delete and truncate commands? : Sql dba

1072


What is rowtype?

1027