zoukankan      html  css  js  c++  java
  • 查看每份数据的记录数,确认数据平均分布

    mysql> select case when created_time >= '2017-01-01' 
        ->              and created_time < '2017-01-02 10:43:20'
        ->             then '2017-01-01'(http://www.amjmh.com/v/BIBRGZ_558768/)
        ->             when created_time >= '2017-01-02 10:43:20'
        ->              and created_time < '2017-01-03 21:26:40'
        ->             then '2017-01-02 10:43:20'
        ->             when created_time >= '2017-01-03 21:26:40' 
        ->              and created_time < '2017-01-05 08:10:00'
        ->             then '2017-01-03 21:26:40' 
        ->             else '2017-01-05 08:10:00'
        ->         end min_dt,
        ->        case when created_time >= '2017-01-01' 
        ->              and created_time < '2017-01-02 10:43:20'
        ->             then '2017-01-02 10:43:20'
        ->             when created_time >= '2017-01-02 10:43:20'
        ->              and created_time < '2017-01-03 21:26:40'
        ->             then '2017-01-03 21:26:40'
        ->             when created_time >= '2017-01-03 21:26:40' 
        ->              and created_time < '2017-01-05 08:10:00'
        ->             then '2017-01-05 08:10:00'
        ->             else '2017-01-06 18:53:20'
        ->         end max_dt,
        ->        count(*)
        ->   from t_source
        ->  group by case when created_time >= '2017-01-01' 
        ->              and created_time < '2017-01-02 10:43:20'
        ->             then '2017-01-01'
        ->             when created_time >= '2017-01-02 10:43:20'
        ->              and created_time < '2017-01-03 21:26:40'
        ->             then '2017-01-02 10:43:20'
        ->             when created_time >= '2017-01-03 21:26:40' 
        ->              and created_time < '2017-01-05 08:10:00'
        ->             then '2017-01-03 21:26:40' 
        ->             else '2017-01-05 08:10:00'
        ->         end,
        ->        case when created_time >= '2017-01-01' 
        ->              and created_time < '2017-01-02 10:43:20'
        ->             then '2017-01-02 10:43:20'
        ->             when created_time >= '2017-01-02 10:43:20'
        ->              and created_time < '2017-01-03 21:26:40'
        ->             then '2017-01-03 21:26:40'
        ->             when created_time >= '2017-01-03 21:26:40' 
        ->              and created_time < '2017-01-05 08:10:00'
        ->             then '2017-01-05 08:10:00'
        ->             else '2017-01-06 18:53:20'
        ->         end;
    +---------------------+---------------------+----------+
    | min_dt              | max_dt              | count(*) |
    +---------------------+---------------------+----------+
    | 2017-01-01          | 2017-01-02 10:43:20 |   249999 |
    | 2017-01-02 10:43:20 | 2017-01-03 21:26:40 |   250000 |
    | 2017-01-03 21:26:40 | 2017-01-05 08:10:00 |   250000 |
    | 2017-01-05 08:10:00 | 2017-01-06 18:53:20 |   250002 |
    +---------------------+---------------------+----------+
    4 rows in set (4.86 sec)
    ---------------------

  • 相关阅读:
    [算法导论]红黑树实现(插入和删除) @ Python
    [算法导论]二叉查找树的实现 @ Python
    [leetcode] Min Stack @ Python
    [leetcode]Find Minimum in Rotated Sorted Array II @ Python
    [leetcode]Find Minimum in Rotated Sorted Array @ Python
    [leetcode]Maximum Product Subarray @ Python
    业余办一个【编程语言+数据结构+算法】培训班怎么样?
    [算法导论]merge sort @ Python
    聚合页是什么?网站聚合页如何做?网站聚合页SEO完全实践指南
    SEO实验:相关性的搜索结果静态页面是否也会在百度劲风算法的处理之中?
  • 原文地址:https://www.cnblogs.com/hyhy904/p/11311227.html
Copyright © 2011-2022 走看看