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!

SQL to get average counts

Ryansun-OracleAug 17 2012 — edited Aug 17 2012
Hi,

I have my table data in the following format
Creation_Date    Salesrep      opportunity id
01-jul-2012     Tim Baker       3123
01--jul-2012    Tim Baker       3124
01-jul-2012     laura  j           3125
02-jul-2012    ted l              3156
.
.
.28-jul-2012    Tim Baker     3158
Basically, this table stores the sales reps who have an sales opportunity assigned to them that they are working on.

1. Now I need to get the Average opportunities by sales rep by week by month along with max and min. The problem with using the standard Avg() funtion is that it could be possible that in a given week, a sales rep has no opportunities at all. So the average does not work correctly.

2. I wanted to get the average number of optys that are created by week and assigned to a sales rep. Now if I use the average standard funtion it adds up only for the data the query returns, I dont think it takes into account if lets say the Sales rep had no opprotunities the whole week.

Thanks,
Sun
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 14 2012
Added on Aug 17 2012
2 comments
595 views