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
Is pl sql and postgresql same?
Explain cursor types?
explain access control lists. : Sql dba
What is a call statement? Explain with an example.
What are the different types of dbms?
What are the types of dbms?
Can variables be used in sql statements?
How do I use google cloud in sql?
What is the starting oracle error number?
What are two statement types in sql?
What is example of database?
What is rank dense_rank and partition in sql?
What is trigger point?
Is sql microsoft?
Can a foreign key be a duplicate?