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 a tablespace? : Sql dba
How to display the records between two range in Oracle SQL Plus?
What does trigger mean in psychology?
Why is stored procedure faster than query?
Why do we use procedures?
how can we find the number of rows in a table using mysql? : Sql dba
what are integrity rules?
how can we take a backup of a mysql table and how can we restore it. ? : Sql dba
What is java sql connection?
What are the disadvantages of file system?
What is flag in sql?
What is a temp table?
Explain the difference between cursor declared in procedures and cursors declared in the package specification?
What is user defined functions?
How to order siblings in oracle hierarchy queries?