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 / mandar

HI, this querey is showing the output for the employees
salary. for the which employees salary is highest in that
table this query showing the output.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is pessimistic concurrency control? : Transact sql

1131


what is a scheduled jobs or what is a scheduled tasks? : Sql dba

1011


What are the limitations of sql express?

1114


Why use subqueries instead of joins?

1133


What is the difference between local variables and global variables?

1171


what is sp_pkeys? : Transact sql

1203


Do triggers have restrictions on the usage of large datatypes, such as long and long raw?

1222


What is sql constant?

1098


Explain how exception handling is done in advance pl/sql?

1043


What is pl/sql language case sensitive?

1180


How do we use distinct statement? What is its use?

1072


What is sql*loader?

1282


What is data definition language?

1135


what are tables and fields? : Sql dba

1095


What is use of package in pl sql?

1067