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 / mandar
HI, this querey is showing the output for the employees
salary. for the which employees salary is highest in that
table this query showing the output.
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
what is a table in a database ? : Sql dba
Which is faster joins or subqueries?
What is duration in sql profiler trace?
What does (*) mean in sql?
What are the main features of cursor?
How can you maintain the integrity of your database on instances where deleting an element in a table result in the deletion of the element(s) within another table?
what is view? : Sql dba
Can a foreign key be a duplicate?
what is the difference between char and varchar data types? : Sql dba
What are sql constraints?
Is merge a dml statement?
What is sql dialect?
What is parameter substitution in sql?
What is update query?
How to select random rows from a table?