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
How many columns should be in an index?
Why primary key is required?
What is sap sql anywhere?
Can you do multiple joins in sql?
What is a column in a table?
Is join an inner join?
What is a sql select statement?
Define select, insert, create, delete, update, drop keywords
What's the difference between a primary key and a clustered index?
what is union? : Sql dba
What is oracle sql called?
explain mysql aggregate functions. : Sql dba
What are the advantages of sql?
Mention what are the benefits of pl/sql packages?
how to include comments in sql statements? : Sql dba