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
What is the mutating table and constraining table?
What are the uses of sysdate and user keywords?
Is primary key clustered index?
Can ddl statements be used in pl/sql?
What port does sql server use?
what is oltp (online transaction processing)? : Sql dba
What are types of exception?
What are the advantages of pl sql over sql?
what is online transaction processing (oltp)? : Sql dba
What is the difference between an inner and outer join?
How do you rename a table in sql?
Explain exception handling in pl/sql?
what is the difference between mysql_fetch_object and mysql_fetch_array? : Sql dba
How to select unique records from a table?
What is AUTH_ID and AUTH_USER in pl/sql ?