您的位置:首页 > 数据库 > MySQL

mysql 统计

2016-09-27 10:19 169 查看
每周:

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 为数据库日期字段
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: