zoukankan      html  css  js  c++  java
  • 半小时分组统计个数sql

    group by 最后一个时间是多少按多少分组

    select count(1), trunc(a.refund_insert_time, 'hh24')
    + case when to_char(refund_insert_time,'mi') >= '30' then numtodsinterval(30,'minute') else numtodsinterval(0,'minute') end
    from refund_record a
    where a.refund_complete_time < sysdate - 1
    group by trunc(a.refund_insert_time, 'hh24')
    + case when to_char(refund_insert_time,'mi') >= '30' then numtodsinterval(30,'minute') else numtodsinterval(0,'minute') end;


    select count(1), trunc(a.refund_insert_time, 'hh24')
    + case when to_char(refund_insert_time,'mi') >= '50' then numtodsinterval(50,'minute')
    when to_char(refund_insert_time,'mi') >= '30' then numtodsinterval(30,'minute')
    else numtodsinterval(0,'minute') end
    from refund_record a
    where a.refund_complete_time < sysdate - 1 and to_char(refund_insert_time,'yyyy-MM-dd hh24')='2016-07-07 09'
    group by trunc(a.refund_insert_time, 'hh24')
    + case when to_char(refund_insert_time,'mi') >= '50' then numtodsinterval(50,'minute')
    when to_char(refund_insert_time,'mi') >= '30' then numtodsinterval(30,'minute')
    else numtodsinterval(0,'minute') end;

     mysql

  • 相关阅读:
    Python日期与时间
    Python文章导航
    Python Tuple元组的操作说明
    Python List列表的操作说明
    Python数字类型及数学运算
    用Python实现一个简单的猜数字游戏
    Python基础语法
    设计模式的六大原则
    设计模式
    设计模式
  • 原文地址:https://www.cnblogs.com/wuer888/p/7280199.html
Copyright © 2011-2022 走看看