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
Can there be more than one function with a similar name in a pl/sql block?
what are the nonstandard string types? : Sql dba
What is the plv (pl/vision) package offers?
What is a sql select statement?
Does sql backup shrink transaction log?
Mention what is the plv (pl/vision) package offers?
What are actual parameters and formal parameters?
how can we repair a mysql table? : Sql dba
What are the advantages of stored procedure?
Is sql open source?
What is the use of index in hive?
What does count (*) do in sql?
Which command is used to call a stored procedure?
Is natural join and inner join same?
What is pl/sql language case sensitive?