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
name 3 ways to get an accurate count of the number of records in a table? : Sql dba
What is a schema? How is it useful in sql servers?
what is bcp? When does it used? : Sql dba
Do stored procedures prevent sql injection?
Can we create index on primary key?
How do I view tables in mysql?
Do we need to create index on primary key?
Can we create foreign key without primary key?
What is rownum and rowid?
Which are the different character-manipulation functions in sql?
How do you run a query?
What will you get by the cursor attribute sql%rowcount?
What is null in pl/sql?
What is update query?
How to revise and re-run the last sql command?