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 |