mysql 统计

每周:

select count(*) as cnt,week(editdate) as weekflg from projects where year(editdate)=2007 group by weekflg

每月:

select count(*) as cnt,month(editdate) as monthflg from projects where year(editdate)=2007 group by monthflg

 

每天:

select count(*) as cnt from projects group by date(editdate)

Demo:

(thinkphp框架)

M('UserCourseSection')
->field('count(*) as nums,left(last_time, 10) as time')
->group('date(last_time)')
->order('last_time desc')
->select();

last_time 为数据库日期字段

posted on 2016-09-27 10:19  studyphp  阅读(201)  评论(0编辑  收藏  举报

导航