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框架)
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 为数据库日期字段
相关文章推荐
- 推荐一个实时统计MySQL read-write ratio的script
- PHP中利用mysql进行访问统计的思路和实现代码
- 发款php蜘蛛统计插件只要有mysql就可用
- mysql 优化几个注意点(非完全统计)
- MySql按周,按月,按日分组统计数据
- mysql 存储过程 获取统计结果
- MySQL 依赖另外一个统计出来数据更新表数据的范例
- MySql的count(*)统计结果很慢?为什么
- PHP+MYSQL 如何准确实现页面访问统计次数
- Mysql 解决 分组统计问题
- shell mysql 查询 赋值 统计
- MYSQL 统计多个字段的和
- 发款php蜘蛛统计插件只要有mysql就可用
- mysql 海量数据统计处理 模拟物化视图
- mysql 统计一周数据
- MYSQL里面统计一个表的列数(即字段数目)怎么查
- mysql得到查询结果的同时统计查询结果的数目
- Mysql 中使用DATE_FORMAT函数按月、周统计数据
- mysql中BIT_COUNT的统计使用
- MySql按周,按月,按日分组统计数据