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

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Question

Re: SQL Question

From: Reinier <Reinier_Dickhout_at_hetnet.nl>
Date: Thu, 2 Nov 2000 15:53:02 +0100
Message-ID: <uaGWHzNRAHA.53@net025s>

If you asume that two employees can hold a shared first, second or third place, as for example in the olympics, and futhermore you asume that if the first or second place is shared there's no third place... then you would like to select every employee where the number of employees with a higher salary is 2 at most.

select *
from emp a
where 2 >= (select count(*) from emp b where b.salary > a.salary);

I didn't test this though.

Reinier.

<xdba_at_my-deja.com> wrote in message news:8trm7t$t7o$1_at_nnrp1.deja.com...
> Given an employees table like this,
> how could I query the top three salaried people per department in SQL?
>
> Dept Name Salary
> 1 Smith 1000
> 1 Jones 2000

<snip> Received on Thu Nov 02 2000 - 08:53:02 CST

Original text of this message

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