• mysql中将查询结果按照时间进行分组和统计


    按照分钟进行统计:
    DATE_FORMAT(create_time, '%Y-%m-%d %H:%i') 
    按照小时进行统计:
    DATE_FORMAT(create_time, '%Y-%m-%d %H') 
    按照天数进行统计:
    DATE_FORMAT(create_time, '%Y-%m-%d') 
    按照月份进行统计:
    DATE_FORMAT(create_time, '%Y-%m-%d') 
     
    按照分钟进行统计:DATE_FORMAT(create_time, '%Y-%m-%d %H:%i') 
    按照小时进行统计:DATE_FORMAT(create_time, '%Y-%m-%d %H') 
    按照天数进行统计:DATE_FORMAT(create_time, '%Y-%m-%d') 
    按照月份进行统计:DATE_FORMAT(create_time, '%Y-%m-%d') 
    
    SELECT
    DATE_FORMAT(create_time, '%Y-%m') createTimeByMin, source,count(1) AS orderCount
    FROM xxx.tablename where biz_code='555'
    AND create_time < '2020-11-07' AND create_time BETWEEN '2020-11-06 13:00:00' AND '2020-11-06 18:31:59'
    GROUP BY createTimeByMin,source;

     

  • 相关阅读:
    三数之和
    167
    二分搜索树
    687
    索引堆
    二分查找 leetcode704
    leetcode 56合并区间 java
    leetcode 1046
    堆的数据结构java
    leetcode 493
  • 原文地址:https://www.cnblogs.com/qianjinyan/p/13961366.html
Copyright © 2020-2023  润新知