Then you can use the week function of mysql in group by clause like this:

SELECT sum(tips) FROM mytable GROUP BY WEEK(date);

This will group your records week by week then will sum each week's tips. Also you can look at http://www.mysql.com/doc/en/Date_and_time_functions.html for the date and time functions in mysql.


[EMAIL PROTECTED] wrote:


On Sun, 13 Jul 2003 11:03:21 +0300, Veysel Harun Sahin wrote:



SELECT week, sum(tips) FROM mytable GROUP BY week;



Sorry, I wasn't clear. I have ONLY daily data, not weekly, but I want to output weekly data.

These are the fields I have:

date DATE NOT NULL,
hours_worked DECIMAL(5,2),
no_of_deliveries TINYINT(1) UNSIGNED,
total_tips DECIMAL(5,2),
gas_used TINYINT(1) UNSIGNED,
notes TEXT

There is no "week" field.

So, I have to compute 'week" by adding together sum(tips) for 7
consecutive days. Any suggestions how I can extract many consecutive
weekly sums?





--


Veysel Harun Sahin
[EMAIL PROTECTED]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to