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 is a trigger word?
How many types of primary keys are there?
What is the life of an sql statement?
Does pl/sql support create command?
What is rowid in sql?
What is fmtonly in sql?
What are %type and %rowtype for?
Can we call procedure in select statement?
What is the use of sqldataadapter?
how to select first 5 records from a table? : Sql dba
What is a scalar value in sql?
Define select, insert, create, delete, update, drop keywords
What are sql built in functions?
What is primary and foreign key?
What is sql key?