Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Second highest value when using group by
Ajit wrote:
> I want to find the second highest salary earner in each department in
> the example below:
>
> ID Department Salary
> 1 101 400
> 2 101 550
> 3 101 500
> 4 201 400
> 5 201 500
>
> The query I am expecting should return this result set:
>
> ID Department Salary
> 3 101 500
> 4 201 400
> Whats the most efficient way of writing SQL for such a problem?
It is the highest one left after excluding the highest one.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace 'x' with 'u' to respond)Received on Mon Dec 06 2004 - 20:48:07 CST