Hi,
(B
(BI have a table with the sales of each product by month (in the format (Byyyymm).
(BFor example: (table name: ventas)
(B
(Bsale_date prod_id sales
(B200301 A 20
(B200302 A 16
(B200303 A 18
(B200301 B 12
(B200302 B 3
(B200304 B 10
(B
(BI would like to have the average sales per month of each product.
(BIf I use:
(B"SELECT prod_id, avg(sales) as average
(B FROM ventas
(B GROUP by prod_id"
(B
(Bthen I would get the average sales from Jan 2003 to Mar 2003 for product A (B(18.0) and the average sales for product B (8.33). (BHowever, as you would have probably noticed, my table covers the sales (Bperiod Jan 2003 to Apr 2003. I would like to get the average sales for the (Bperiod Jan-Apr 2003 for each product: A (13.5) and B (6.25).
(B
(BI know that if I add the missing lines with value 0 the problem would be (Bsolved, but I would like to know an efficient way to add those lines (Bwithout having to check the table for missing values with a script (I also (Bneed to calculate the standard deviation).
(B
(BThanks in advance for your help.
(B
(Bkelwin
(B
(B_________________________________________________________________
$BM'C#$H(B24$B;~4V%[%C%H%i%$%s!V(BMSN $B%a%C%;%s%8%c!http://messenger.msn.co.jp (B
(B
(B-- (BMySQL General Mailing List
(BFor list archives: http://lists.mysql.com/mysql
(BTo unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to