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
Do stored procedures prevent sql injection?
How do you write an index?
how to enter numeric values as hex numbers? : Sql dba
How do I find duplicates in the same column?
What are the types of join in sql?
Is there any restriction on the use of union in embedded sql?
What is the usage of nvl function?
Enlist the data types that can be used in pl/sql?
Do we need to rebuild index after truncate?
How do I order columns in sql?
Does group by remove duplicates?
How does sql store data?
what are integrity rules?
What are the types of queries in sql?
what is top in tsql? : Transact sql