Re: Need SQL guru's help: Best query?
Date: 1996/03/25
Message-ID: <827789823snz_at_zc07.demon.co.uk>#1/1
In article <4j65bp$fee_at_castle.nando.net>
cfischer_at_nando.net "Chris Fischer" writes:
> cdye_at_dnt.dialog.com (Charles Dye (PC)) wrote:
>
> >SELECT model_number, min(model_number)
> >FROM model_table
> >group by model_number
> >order by model_number
> >/
>
> In this case, the ORDER BY clause is redundant and unnecessary as to
> do the GROUP BY oracle will already sort the rows. Adding the order
> by simply causes oracle to sort the rows again.
>
I always thought the same, but I was recently debugging a Pro*C program when I noticed that the data wasn't being output in the order I expected. Adding the "order by" clause after "group by" fixed it. I checked in the SQL Language Reference manual and there is no mention of "group by" returning the results in any particular order.
This was on 7.1.6
-- Ian ScottReceived on Mon Mar 25 1996 - 00:00:00 CET