按月进行统计
[sql]select DATE_FORMAT(date,'%Y-%m') as month,sum(money) as moneyfrom financewhere DATE_FORMAT(date,'%Y')=2010 group by monthorder by month[/sql]
按周统计
查看MySQL的manual%X Year for the week where Sunday is the first day of the week, numeric, four digits; used with %V%x Year for the week, where Monday is the first day of the week, numeric, four digits; used with %v其中1如果周一为一周的第一天,则(小写) DATE_FORMAT(date,'%x %v')2如果周日为一周的第一天,则(大写) DATE_FORMAT(date,'%X %V')[sql]select DATE_FORMAT(date,'%x年-第%v周') as week,sum(money) as money from finance_base where DATE_FORMAT(date,'%Y')=2010 group by weekselect DATE_FORMAT(date,'%x年-第%v周') as week,sum(money) as money from finance_base where DATE_FORMAT(date,'%Y')=2010 group by week[/sql]