Re: group by/order by problem
Date: Sun, 23 May 2010 10:17:21 -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)
I got the database restructured, and the revised code debugged. I tried out a query w/ a nested query like you suggested and it worked. Many thanks!
However I'm not sure what you mean by 'materialize' the inner view. If there were no group by, there wouldn't be an issue - the order by would 'materialize' whatever query it was a clause of, whatever 'materialize' means. Why does the group by mean the order by can't to the same thing, if instead of a nested query, I simply append the order by clause to the group by query?
I'm hope you understand how I don't understand, if you know what I mean.
Again many thanks. It's enabled my project to lurch forward!
Ken Quirici Received on Sun May 23 2010 - 12:17:21 CDT