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
how many groups of data types? : Sql dba
What is date functions?
What are the differences between in and exists clause?
How do you delete duplicates in sql query using rowid?
Can I call a procedure inside a function?
what is self-join? : Sql dba
What are the disadvantages of file system?
Can we use pl sql in mysql?
Why we use cross join?
Can I learn sql in a week?
Is ms sql traffic encrypted?
What is trigger in pl sql?
What is the need of a partition key?
what is the difference between delete and truncate commands? : Sql dba
What is rowtype?