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 are sql indexes?
Why use stored procedures?
What is the size of partition table?
What are user defined functions?
what is the difference between truncate and drop statements? : Sql dba
What is scalar function in sql?
what are the types of join and explain each? : Sql dba
what is a control file ? : Sql dba
How can we link a sql database to an existing android app?
What is database white box testing and black box testing?
What are the commands used in sql?
What is varchar example?
What is java sql drivermanager?
What does a pl/sql package consist of?
What is left join example?