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
Explain alias in sql?
Why schema is used in sql?
Can you load data into multiple tables at once? : aql loader
What are the datatypes available in pl/sql ?
Mention what is the plv (pl/vision) package offers?
What is full join in sql?
What is a ddl command?
what is a table called, if it has neither cluster nor non-cluster index? What is it used for? : Sql dba
Where are my tempfiles, I don't see them in v$datafile or dba_data_file?
how do you know if your mysql server is alive? : Sql dba
What are aggregate and scalar functions?
What is substitution variable in pl sql?
Can we debug stored procedure?
What is the difference between sql and isql*plus?
Can a trigger call a stored procedure?