根据日统计:
select year(create_datetime),month(create_datetime),day(create_datetime),count(*) from redpacket group by year(create_datetime),month(create_datetime), day(create_datetime);
根据周统计:
select FROM_DAYS(TO_DAYS(create_datetime) -MOD(TO_DAYS(create_datetime) -2, 7)) AS week from redpacket group by week;
根据月统计:
select count(*) from redpacket group by year(create_datetime),month(create_datetime);
本文出自 “一个程序媛的自我修养” 博客,请务必保留此出处http://qianqiansun.blog.51cto.com/13271301/1971273
原文:http://qianqiansun.blog.51cto.com/13271301/1971273