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

Home -> Community -> Usenet -> c.d.o.misc -> Re: 8i vs 9i: Difference in "group by" ?

Re: 8i vs 9i: Difference in "group by" ?

From: Thomas Kyte <tkyte_at_oracle.com>
Date: 4 Jun 2002 07:20:49 -0700
Message-ID: <adiic10cn9@drn.newsguy.com>


In article <adgk2s$30c$2_at_reader1.panix.com>, "R says...
>
>Hi Tom, how about the DISTINCT function ?
>ie select distinct sale_date from sales;
>Can I avoid a sort here ?
>thanks
>Robert

The *only* way -- repeat -- the ONLY way to get an ordered result set is .... to use ORDER BY

period, end of statement -- nothing else to be said. If the optimizer uses a "distincting" step that happens to order the results -- it'll do the right thing (as little work as needed).

If you want the data ordered, you MUST use an order by.

>
>
>>group by NEVER had to sort -- I can give you examples all of the way back
>to 7.0
>>whereby the group by doesn't sort.
>>
>>It never had it.
>>It never was assured.
>>
>>The *only* way -- repeat -- the ONLY way to get an ordered result set is
>.... to
>>use ORDER BY
>
>

--
Thomas Kyte (tkyte@oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Tue Jun 04 2002 - 09:20:49 CDT

Original text of this message

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