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

Home -> Community -> Usenet -> c.d.o.tools -> Re: sql aggregate question

Re: sql aggregate question

From: Myron Wintonyk <mwintony_at_med.ualberta.ca>
Date: Thu, 18 Jan 2001 10:35:05 +1000
Message-ID: <3A663A39.F777BDCC@med.ualberta.ca>

select team, name, score from players A

        where score = ( select max( score)
                                 from players B
                                 where A.PLAYER = B.PLAYER
                                     and A.TEAM = B.TEAM );

Would return:
A job 20
A bob 20
B bill 30
C leo 50

( Not necessarilty in that order).

Doug Edmunds wrote:

> Given a table players
> with fields
> name char, score number, team char
>
> and data thus
> tom, 10, A
> joe, 20, A
> bob, 20, A
> fred, 20, B
> mark, 25, B
> bill, 30, B
> alex, 30, C
> mike, 40, C
> leo, 50, C
>
> how do I modify
>
> select max(score), team
> from players
> group by team;
>
> so it includes the name of the player(s)
> with the high score on each team?
>
> results wanted:
> joe, 20, A
> bob, 20, A
> bill, 30, B
> leo, 50, C
>
> Thanks.
> -- doug edmunds
> 17 Jan 2001
  Received on Wed Jan 17 2001 - 18:35:05 CST

Original text of this message

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