dbTalk Databases Forums  

How to find daily avg and stdev from sales table, when some days sales are zero?

comp.database.oracle comp.database.oracle


Discuss How to find daily avg and stdev from sales table, when some days sales are zero? in the comp.database.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Matthew Wilson
 
Posts: n/a

Default How to find daily avg and stdev from sales table, when some days sales are zero? - 09-13-2006 , 11:32 AM






Hopefully the subject said it all.

I have a sales table with a row per sale and each row has a sale_date
column.

I want to calculate average sales and the standard deviation of sales
for a time period.

I was trying something like

select avg(cnt), stdev(cnt) from
(
select to_char(sale_date, 'mon dd yyyy'), count(*) as cnt
from sales_data
group by to_char(sale_date, 'mon dd yyyy')
)

But then I discovered that my averages were too high because on any day
that I had no sales, it wouldn't get included in the outer query.

All tips are welcome.

Matt


--
A better way of running series of SAS programs:
http://overlook.homelinux.net/wilson...asAndMakefiles

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.