Re: group by/order by problem
Date: Sun, 23 May 2010 09:29:44 -0700 (PDT)
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.
> Vladimir M. Zakharychev
> N-Networks, makers of Dynamic PSP(tm)
Thanks for your reply.
I've changed the database structure in the meantime and haven't
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.
Ken Quirici Received on Sun May 23 2010 - 11:29:44 CDT