Table finance has two fields as follows
Date Date
Money Double (15,2)
The 2010 financial data for the table finance is required below and is counted monthly
SQL code
Select Date_format (date, '%y-%m ') as Month,sum (money) as the
finance
where date_format (date, '%Y ') =2010
GROUP BY month order by
month
Here is the weekly statistic
View MySQL's Manual
%x for the "week where Sunday is" the "the" The week, numeric, four digits; Used with%V
%x for the "week, where Monday is the" the "the" The week, numeric, four digits; Used with%v
which
1 if Monday is the first day of the week (lowercase) date_format (DATE, '%x%v ')
2 If Sunday is the first day of the week (uppercase) Date_format (DATE, '%x%V ')
SQL code
Select Date_format (date, '%x-%v week ') as Week,sum (money)
as the Finance_base
where date_format (date, '%Y ' ) =2010
GROUP by week