---
title: "按分钟时间段统计"
author: "ywChen"
date: "2012-04-13T15:33:56Z"
tags: []
categories: ["数据库"]
slug: "untitled"
draft: false
lastmod: "2012-04-13T15:33:56Z"
id: 1485364
url: "https://ywchen.iteye.com/blog/1485364"
---

```
select

 to_char((trunc(sysdate) +
         trunc((end_time - trunc(sysdate)) * 24 * 60 / 40) * 40 / 60 / 24),
         'hh24:mi') || '-' ||
 to_char((trunc(sysdate) +
         trunc((end_time - trunc(sysdate)) * 24 * 60 / 40 + 1) * 40 / 60 / 24),
         'hh24:mi') period,
 
 sum(run_times) "ROWS",
 flow_node_code

  from tb_soc_flow_node_status

 group by to_char((trunc(sysdate) +
                  trunc((end_time - trunc(sysdate)) * 24 * 60 / 40) * 40 / 60 / 24),
                  'hh24:mi') || '-' ||
          to_char((trunc(sysdate) +
                  trunc((end_time - trunc(sysdate)) * 24 * 60 / 40 + 1) * 40 / 60 / 24),
                  'hh24:mi'),
          flow_node_code
```

 

![](http://dl.iteye.com/upload/attachment/0066/5339/03f4e1d1-2d1f-3a13-bbd0-0fb9ad27ac1f.jpg)