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


Please Help Members By Posting Answers For Below Questions

What does plv msg allows you to do?

674


What is the benefit of foreign key?

526


Explain normalization and what are the advantages of it?

517


What is pivot in sql?

510


What is an emotional trigger?

517






What does the hierarchical profiler does?

567


How do you write an index?

527


What is a sql*loader control file?

618


Suppose a student column has two columns, name and marks. How to get name and marks of the top three students.

527


What is execute immediate?

549


What is the difference between microsoft access and sql server?

532


Does view contain data?

616


What are the possible values for the boolean data field?

522


what are the difference between clustered and a non-clustered index? : Sql dba

528


What is Materialized View? In What Scenario we Use Materialized View?

8526