Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Averaging an Average

user11204958Mar 1 2010 — edited May 25 2010
I'm trying to average an average and I'm running into a bit of trouble. I want to determine a daily average of sales and then average the daily averages. So, if I have 3 sales for Day 1 ($5, $10 and $15, average sale being $10) and 4 sales for Day 2 ($1, $2, $3 and $4, average sale being $2.50), I want to average those together. Total Sales (Avg: $10 and $2.50).

I made some progress, by using the PARTION BY function, but the problem is that I can't run an average...

SELECT a.month, a.sales, AVG(a.sales) OVER(PARTITION BY a.day ) AS Daily_Sales
FROM schema.profits a

But now I want to be able to Average that Daily_Sales calculation and then group by the month to get my final result. However, when I try to add in average to the daily_sales, I get "ORA-30483: window functions are not allowed here". Any ideas?

Thanks,
Jeff C.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 22 2010
Added on Mar 1 2010
5 comments
1,177 views