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
Does db2 use sql?
Can we debug stored procedure?
Why do we create views in sql?
what is the difference between myisam static and myisam dynamic? : Sql dba
What does subquery mean in sql?
What is the difference between microsoft sql and mysql?
What is normalisation and its types?
hi,i plan to put experience on PLSQL ,can anyone suggest me for any institutes in bangalore or how to prepare for interviews
What is a field in a database?
How does cross join work in sql?
Explain the order of sql statement execution?
What is aggregate function in sql?
What is sqlcontext?
What is the difference between left outer join and left join?
What is sqlservr exe?