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 / nitin
Thank you.
Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Is foreign key mandatory?
What is sql scripting?
What is difference between hql and sql?
What are the two types of cursors in pl sql?
What are keys in sql?
How delete all data from all tables in sql?
what are all the different types of indexes? : Sql dba
Does a primary key have to be a number?
How do I partition a table in sql?
How to create an array in pl/sql?
what are the advantages of sql ? : Sql dba
How do we accept inputs from user during runtime?
What are the operators in sql?
Can we delete column in sql?
How to find 3rd highest salary of an employee from the employee table in sql?