Home » SQL & PL/SQL » SQL & PL/SQL » finding the nth salary
finding the nth salary [message #239818] Wed, 23 May 2007 06:35 Go to next message
Messages: 3
Registered: May 2007
Location: Delhi
Junior Member

Dear All,

Can anyone tell me the the procedure or the intricacies going under finding the nth highest/lowest salary.

like i have a query:

select distinct sal from emp e where 1 = (select count(distinct sal) from emp b where e.sal < b.sal)

it will find the 2nd highest salary But how it exactly works on Can anone explain it out.

Sumit Sharma
Re: finding the nth salary [message #239825 is a reply to message #239818] Wed, 23 May 2007 06:51 Go to previous message
Michel Cadot
Messages: 65150
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
As this has been answered many and many times I think a little search will (would) give you the answer.

Btw, explain what don't you understand in the query?
Just follow it from inner part (right one here) to outer.


[Updated on: Wed, 23 May 2007 06:52]

Report message to a moderator

Previous Topic: Difference between inner join and equijoin
Next Topic: multiple values in a string causing stored procedure to hang even after commiting the data
Goto Forum:

Current Time: Mon Aug 21 20:53:16 CDT 2017

Total time taken to generate the page: 0.02356 seconds