Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Second highest value when using group by

Re: Second highest value when using group by

From: DA Morgan <damorgan_at_x.washington.edu>
Date: Mon, 06 Dec 2004 18:48:07 -0800
Message-ID: <1102387583.464505@yasure>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US