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: Compute weighted average

Re: Compute weighted average

From: Robert Klemme <shortcutter_at_googlemail.com>
Date: Tue, 10 Oct 2006 13:29:30 +0200
Message-ID: <4p1egqFgpc5cU2@individual.net>


On 07.10.2006 08:06, Michel Cadot wrote:
> "Robert Klemme" <shortcutter_at_googlemail.com> a écrit dans le message de news: 4onog8Ffjh9aU1_at_individual.net...
> Can't you put them together into a single "over" clause?
>
> select month, value, weight,
> sum(weight*value) / sum(weight) over (order by month) wavg
> from t
> order by month
>
> Or am I missing something here?
>
> robert
>
> -------------------------------------------
>
> No you can't.
> In this case the window clause only applies to the second sum function,
> the first is a classical group function.and not a window (analytic) one:
>
> SQL> select month, value, weight,
> 2 sum(weight*value) / sum(weight) over (order by month) wavg
> 3 from t
> 4 order by month
> 5 /
> select month, value, weight,
> *
> ERROR at line 1:
> ORA-00937: not a single-group group function

Thanks for the clarification!

        robert Received on Tue Oct 10 2006 - 06:29:30 CDT

Original text of this message

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