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

Home -> Community -> Usenet -> c.d.o.server -> Re: Top N Results From Aggregate Values in A Select

Re: Top N Results From Aggregate Values in A Select

From: SL <sebastien_louchart_at_yahoo.fr>
Date: 8 Dec 2005 12:54:51 -0800
Message-ID: <1134075291.673168.47970@f14g2000cwb.googlegroups.com>


>But would the rank function do this more efficiently?
I dunno. Try to explain_plan both versions. I prefer to use the analytic functions when I don't need groups or aggregates or when I want to retrieve some columns I don't want to be part of the aggregate : by specifying a PARTITION clause within my analytic functions, I can achieve that.

> I am having a
>great deal of difficulty understanding the whole analytical processing
>aspect of Oracle.

PARTITION is equivalent to have a group by in your selection list, grouping is sort of done once the rows of your resulset are retrieved. ORDER BY clause lets you to apply an order to your rows for the purpose of your calculations with analytic functions and spare the main ORDER BY clause of your query to nicely present your results. Have a look to the samples in the manual, they are quite explicit and helpful.
Keep in mind that analytic functions are the last things to be processed during query execution, these calculations occur after row retrieving, group by aggregating but before sorting.

HTH

-- 
SL
Received on Thu Dec 08 2005 - 14:54:51 CST

Original text of this message

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