oracle 按小时统计表中各小时的数据量条数

 时间:2024-11-10 04:51:59

1、以下,例如,统计2016年5月06号一天各个小时内的数据量有多少,表名:TASK_RESULT, 统计按照stat_date字段的时间统计

2、select s.stat_date, 衡痕贤伎s.data_num from (select to_char(stat_date, '烤恤鹇灭yyyy/mm/dd hh24') || '点' as stat_date, count(1) as data_num from TASK_RESULT t where t.stat_date >= to_date('20160506', 'yyyymmdd') and t.stat_date < to_date('20160507', 'yyyymmdd') group by to_char(stat_date, 'yyyy/mm/dd hh24') || '点') s

3、注意,时间格式要用yyyy.mm.dd hh24,不要用hh,那样早上九点和晚上九点的就统计到一起了,因为hh是12小时制,统计结果,如下图:

oracle 按小时统计表中各小时的数据量条数

4、按15分钟统计,如下SQL:select count(*), (case floor((to_char(stat_date, 'mi')) / 15像粜杵泳) when 0 then to_char(stat_date, 'yyyy.mm.dd hh24') || ':00:00' when 1 then to_char(stat_date, 'yyyy.mm.dd hh24') || ':15:00' when 2 then to_char(stat_date, 'yyyy.mm.dd hh24') || ':30:00' when 3 then to_char(stat_date, 'yyyy.mm.dd hh24') || ':45:00' end) as stat_date from TASK_RESULT s where s.stat_date >= to_date('20160506', 'yyyymmdd') and s.stat_date < to_date('20160507', 'yyyymmdd')group by stat_date

5、统计结果,如下图:

oracle 按小时统计表中各小时的数据量条数
  • IDEA如何连接Oracle数据库
  • windows上 route 命令的说明教程
  • C#怎么创建Datatable
  • 如何使用SQL Developer导出表数据到sql文件
  • PythonGUI系列:tkinter之Text制作表格
  • 热门搜索
    dnf怎么附魔 推荐信怎么写 江西财经大学怎么样 雨刮器怎么拆 下巴长痘怎么办 男人怎么减肥 怎么求婚 怎么让ppt自动播放 婴儿吐奶严重怎么办 怎么样在网上赚钱