每周:

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 统计的更多相关文章

  1. mysql统计类似SQL语句查询次数

    mysql统计类似SQL语句查询次数 vc-mysql-sniffer 工具抓取的sql分析. 1.先用shell脚本把所有enter符号替换为null,再根据语句前后的字符分隔语句 grep -Ev ...

  2. 【mysql】mysql统计查询count的效率优化问题

    mysql统计查询count的效率优化问题 涉及到一个问题 就是 mysql的二级索引的问题,聚簇索引和非聚簇索引 引申地址:https://www.cnblogs.com/sxdcgaq8080/p ...

  3. mysql统计天、周、月、季度、半年、年

    之前在网上搜索按时间统计,发现不是很全 ,接着别人的思路进行延伸下, mysql统计天.周.月.季度.半年.年 前期工作创建辅助表 CREATE TABLE num (i INT); ),(),(), ...

  4. PHP+Mysql统计文件下载次数实例

    PHP+Mysql统计文件下载次数实例,实现的原理也很简单,是通过前台点击链接download.php传参id,来更新点击次数. 获取文件列表: <?php require 'conn.php' ...

  5. MySQL统计信息简介

    作者:王小龙@网易乐得DBA 原文地址: http://mp.weixin.qq.com/s/698g5lm9CWqbU0B_p0nLMw MySQL执行SQL会经过SQL解析和查询优化的过程,解析器 ...

  6. Mysql统计每年每个月的数据——详细教程

    Mysql统计每年每个月的数据(前端页面统计图实现) 最终想实现的效果图,在这里就不多废话了,直接上效果图,由于测试数据有几个月是为0的,所以数据图看着会有点怪怪. 接下来是数据库的两个表,这里直接给 ...

  7. mysql统计指定数据库的各表的条数

    mysql统计指定数据库的各表的条数 SELECT table_schema,table_name,table_rows,CREATE_TIME FROM TABLES WHERE TABLE_SCH ...

  8. mysql统计一张表中条目个数的方法

    统计一张表中条目的个通常的SQL语句是: select count(*) from tableName; #or ) from tableName; #or 统计一个列项,如ID select cou ...

  9. MySQL统计信息以及执行计划预估方式初探

    数据库中的统计信息在不同(精确)程度上描述了表中数据的分布情况,执行计划通过统计信息获取符合查询条件的数据大小(行数),来指导执行计划的生成.在以Oracle和SQLServer为代表的商业数据库,和 ...

  10. 实战:mysql统计指定架构的全部表的数据和索引大小情况-v2

    PS:第一个版本号里未做输入的schema_name和table_name推断,改动了一下!再次share! #统计指定架构的全部表的数据和索引大小情况 #tablesize.sh #!/bin/sh ...

随机推荐

  1. CodeVS 数轴染色

    #include<cstdio> #include<algorithm> using namespace std; #define lson rt<<1 #defi ...

  2. Linux 服务器的网络配置 - 2. 查看 Linux 服务器的进程

    2. 查看 Linux 服务器的进程 1)ps [主要选项] -a  显示系统中所有进程的信息 -e  显示所有进程的信息 -f  显示进行的所有信息 -l   以长格式显示进程信息 -r  只显示正 ...

  3. 65. Reverse Integer && Palindrome Number

    Reverse Integer Reverse digits of an integer. Example1: x =  123, return  321 Example2: x = -123, re ...

  4. spring定时器设置(转自:http://my.oschina.net/LvSantorini/blog/520049)

    转自:http://my.oschina.net/LvSantorini/blog/520049<!-- MessageRequestTask类中包含了msgRequest方法,用于执行定时任务 ...

  5. 解决activity加上Theme.Translucent.NoTitleBar 页面跳转显示桌面

    自定义style 继承Theme.Translucent.NoTitleBar       <style name="My.Translucent" parent=" ...

  6. 解决Windows8下Cisco Systems VPN Client的Reason 442: Failed to Enable Virtual Adapter错误

    Windows8下使用Cisco Systems VPN Client创建的Cisco IPSec VPN无法连接,提示Reason 442: Failed to Enable Virtual Ada ...

  7. javascript立即执行函数 (function(){})()

    看到一段代码: (function(){ var outer = $('#subject'); outer.find('li').on('mouseover', mouseover); })() ( ...

  8. SSH整合(1)异常

    信息: No Spring WebApplicationInitializer types detected on classpath 十二月 01, 2016 10:06:12 下午 org.apa ...

  9. 去除DEDECMS后台预览文章URL地址多余的数字信息

    在使用织梦模板时发现这样一个问题:在后台预览文章的时候,出现的文章网址尽管是静态URL,但是会在网址的尾部出现问号并跟随一个时间戳,在复制URL时就显得很不方便.那么如何解决这一问题呢? 经过查找资料 ...

  10. 百度地图API示例之根据城市名设置地图中心点

    代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" con ...