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 pl sql architecture?
How do I copy a table in sql?
What are the types of optimization?
How many triggers can be applied on a table?
what is meant by urlencode and urldocode? : Sql dba
Can we use delete in merge statement?
What is a boolean in sql?
How do I create an index in word?
what is the difference between delete and truncate statement in sql? : Sql dba
what are the join types in tsql? : Transact sql
how to use case expression? : Sql dba
What are the ways on commenting in a pl/sql code?
how to extract a unit value from a date and time? : Sql dba
What is sql select statement?
Explain foreign key in sql?