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 the mutating table and constraining table?

556


What are the uses of sysdate and user keywords?

628


Is primary key clustered index?

518


Can ddl statements be used in pl/sql?

594


What port does sql server use?

504






what is oltp (online transaction processing)? : Sql dba

530


What are types of exception?

534


What are the advantages of pl sql over sql?

546


what is online transaction processing (oltp)? : Sql dba

526


What is the difference between an inner and outer join?

537


How do you rename a table in sql?

532


Explain exception handling in pl/sql?

530


what is the difference between mysql_fetch_object and mysql_fetch_array? : Sql dba

552


How to select unique records from a table?

569


What is AUTH_ID and AUTH_USER in pl/sql ?

1690