1、按小时统计的语句

    select
    concat(date_format(gmt_create, "%Y-%m-%d %k:00~"), hour(gmt_create)+1, ":00") as 'time',
    count(*) as num
    from t_order
    where gmt_create>='2016-03-06 00:00:00' and gmt_create<='2016-03-06 23:59:59'
    group by left(gmt_create, 13);

    select
    concat(date_format(gmt_create, "%Y-%m-%d %k:00~"), hour(gmt_create)+1, ":00") as 'time',
    count(*) as num
    from t_order
    where gmt_create>='2016-03-06 00:00:00' and gmt_create<='2016-03-06 23:59:59'
    group by date_format(a.gmt_create,'%Y-%m-%d %H:00');

  2、加上序号
    select
    (@rowNO := @rowNo+1) as rowno,
    concat(date_format(a.gmt_create, "%Y-%m-%d %k:00~"), hour(a.gmt_create)+1, ":00") as 'time',
    count(*) as num
    from t_order a,(select @rowNO :=0) b
    where a.gmt_create>='2016-03-06 00:00:00' and a.gmt_create<='2016-03-06 23:59:59'
    group by date_format(a.gmt_create,'%Y-%m-%d %H:00');

  3、环比,就是相邻时间段的对比。如:14年4月和14年3月是相邻时间段,这两个时间段的数据对比,就是环比。
    select date_format(a.m_adddate,'%Y-%m') as 时间, count(*) as `当月`,
    (select count(*) from job_myreceive where date_format(a.m_adddate,'%Y%m') = date_format(date_add(m_adddate,interval 1 month),'%Y%m')) as 上月
    from job_myreceive a group by 1

  4、同比,是指在相邻时段中的某一相同时间点进行比较。
    如:13年和14年是相邻时段,13年3月和14年3月是这两个相邻时段的同一个时间点,都是3月,这两个时段进行数据对比,就是同比。

  5、查看数据库的大小,结果是以字节为单位,除1024为K,除1048576为M。
    select TABLE_SCHEMA '数据库名',(sum(DATA_LENGTH)+sum(INDEX_LENGTH))/1048576 '大小(M)' from information_schema.tables where TABLE_SCHEMA='xiancheng';

  6、查看表的大小,结果是以字节为单位,除1024为K,除1048576为M。
    select TABLE_NAME '表名',(DATA_LENGTH+INDEX_LENGTH)/1048576 '大小(M)' from information_schema.tables where TABLE_SCHEMA='xiancheng';

最新文章

  1. mysql数据库开发常见问题及优化
  2. Redis-复制
  3. Always review
  4. SQLSTATE[HY000] [2003] Cant connect to MySQL server
  5. nginx服务器在IE下载时,apk,ipa文件变成zip的解决方法
  6. shell timeout
  7. uva 11825 Hackers&amp;#39; Crackdown (状压dp,子集枚举)
  8. CentOS6.7 用户
  9. qt model/view 架构基础介绍之QListWidget
  10. hdu 4751 Divide Groups(dfs染色 或 2-sat)
  11. Drying(贪心)
  12. 模块化写法-IIFE解析
  13. C++ Primer Plus 6 第二章
  14. Sql 的 RAISERROR用法
  15. java各种概念 Core Java总结
  16. Update API
  17. 使用blas做矩阵乘法
  18. Windows10右键添加&quot;在此处打开命令窗口&quot;
  19. mysql5.7如何修改密码以及密码如何忘记无密码登陆
  20. E - A Twisty Movement

热门文章

  1. 洛谷 P1181 数列分段Section I【贪心/最少分成多少合法的连续若干段】
  2. Python的功能模块[4] -&gt; pdb/ipdb -&gt; 实现 Python 的单步调试
  3. 大数据技术之_16_Scala学习_09_函数式编程-高级
  4. poj2976(01分数规划)
  5. MySQL注入工具sqlsus
  6. [LOJ6280]数列分块入门 4
  7. List和ArrayList的区别和联系
  8. iOS 设置系统音量和监听系统音量变化
  9. iPhone 通过UIRequiredDeviceCapabilities指定程序适用于哪些设备
  10. C#如何把日期转成YYYYMMDDHHMMSSFFF的精确到毫秒的格式?