MySQL-按月统计数据

MySQL—-按月统计数据

统计2010年 每月的资金

select DATE_FORMAT(date,'%Y-%m') as month,sum(money) as money 
from finance 
where DATE_FORMAT(date,'%Y')=2010 
group by month 
order by month

1如果周一为一周的第一天,则(小写) DATE_FORMAT(date,’%x %v’)

2如果周日为一周的第一天,则(大写) DATE_FORMAT(date,’%X %V’)

统计每个星期

select DATE_FORMAT(date,'%x年-第%v周') as week,sum(money) as money 
from finance_base 
where DATE_FORMAT(date,'%Y')=2010 
group by week

MySQL-按月统计数据

相关文章:

你感兴趣的文章:

标签云: