Re: MAX/DISTINCT in one query

From: Amar <bg22456_at_binghamton.edu>
Date: Thu, 17 Dec 1998 00:11:01 -0500
Message-ID: <3678948f.0_at_bingnews.binghamton.edu>


>Sunder wrote in message ...
> emp_num , dept, salary
>
> I want to select the dept,empl_num and salary of the empl with max
>salary in each dept.
>
>ex
>
>emp no dept salary
>1000 10 1000
>1001 10 2000
>1002 20 1500
>1003 20 1100
>
>The output of the query should be
>
>emp no dept salary
>1001 10 2000
>1002 20 1500.
>
>Can anybody tell me how this can be accomplished .
>
>Sunder
>

Hi Sunder,

Was this what u were looking for ?

select * from emp where salary in (select max(salary) from emp group by dept) order by dept;

Regards,
Amar Received on Thu Dec 17 1998 - 06:11:01 CET

Original text of this message