Re: group by/order by problem

From: Ken Quirici <kquirici_at_yahoo.com>
Date: Sun, 23 May 2010 09:29:44 -0700 (PDT)
Message-ID: <744d935a-3754-471a-98c0-7f73899fef43_at_v18g2000vbc.googlegroups.com>



On May 23, 11:54 am, "Vladimir M. Zakharychev" <vladimir.zakharyc..._at_gmail.com> wrote:
> On May 23, 6:45 pm, Ken Quirici <kquir..._at_yahoo.com> wrote:
>
>
>
> > Hi,
>
> > The following query:
>
> > select
> > player,
> > sum(hp) thp
> > from b_data
> > where hp = 1
> > group by player
> > order by thp
> > ;
>
> > does not sort the results either by player or thp.
>
> > Is there some logical reason for this, or is order by only
> > designed to sort group by's by the group by column?
>
> > Basically, how can I get it to sort by thp?
>
> > Any help MUCH appreciated.
>
> > Regards,
>
> > Ken Quirici
>
> select player, thp
>   from (select player, sum(hp) thp
>           from b_data
>          where hp = 1
>          group by player)
>  order by thp;
>
> To order by thp Oracle needs to "materialize" the inner view, so you
> need to give it a chance to do so.
>
> Hth,
>    Vladimir M. Zakharychev
>    N-Networks, makers of Dynamic PSP(tm)
>    http://www.dynamicpsp.com

Hi Vladimir,

Thanks for your reply.

I've changed the database structure in the meantime and haven't changed the
code to repopulate it, so I can't check your revised version yet.

However you don't need to 'materialize' the inner view in something like

group by player
order by player

which works fine.

Any thoughts?

Regards,

Ken Quirici Received on Sun May 23 2010 - 11:29:44 CDT

Original text of this message