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 / ms75
Detailed answer available on following weblinks
-----------------------------------------------
1) How does this query work?
<http://www.sqlteam.com/article/find-nth-maximum-value-in-
sql-server>
2) How this query works?
<http://www.dbapool.com/forumthread/topic_4361.html>
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What are the indexing methods?
Do triggers have restrictions on the usage of large datatypes, such as long and long raw?
How many types of triggers are there in pl sql?
What is bind variable in pl sql?
Which column in the user.triggers data dictionary view shows that the trigger is a pl/sql trigger?
What are the benefits of triggers?
what is error ora-03113: end-of-file on communication channel?
What are different categories of sql commands?
Explain two easy sql optimizations.
What are the different type of joins in sql?
How do you create an update query?
What is a crud api?
Explain what is a subquery ?
What are tuples in sql?
how to drop an existing index in mysql? : Sql dba