好的,我在PostgreSQL中有这样一个表:
timestamp duration
2013-04-03 15:44:58 4
2013-04-03 15:56:12 2
2013-04-03 16:13:17 9
2013-04-03 16:16:30 3
2013-04-03 16:29:52 1
2013-04-03 16:38:25 1
2013-04-03 16:41:37 9
2013-04-03 16:44:49 1
2013-04-03 17:01:07 9
2013-04-03 17:07:48 1
2013-04-03 17:11:00 2
2013-04-03 17:11:16 2
2013-04-03 17:15:17 1
2013-04-03 17:16:53 4
2013-04-03 17:20:37 9
2013-04-03 17:20:53 3
2013-04-03 17:25:48 3
2013-04-03 17:29:26 1
2013-04-03 17:32:38 9
2013-04-03 17:36:55 4
我想获得以下输出:
时间戳窗口开始 = 2013-04-03 15:44:58
duration count
1 0
2 1
3 0
4 1
9 0
时间戳窗口开始时间为2013年4月3日 15:59:58。
duration count
1 0
2 0
3 0
4 0
9 1
时间戳窗口开始时间为2013年4月3日16时14分58秒。
duration count
1 1
2 0
3 1
4 0
9 0
时间戳窗口开始时间为2013年4月3日16:29:58。
duration count
1 2
2 0
3 0
4 0
9 1
基本上,它在15分钟的时间窗口内循环,并输出不同的持续时间值以及它们的频率(计数)。timestampwindowstart值是窗口的最早时间戳(即timestampwindowfinish = timestampwindowstart + 15分钟)。
这样我就可以绘制15分钟间隔的直方图了...
我已经尝试阅读,但对我来说有点复杂,而且时间不多...
感谢任何帮助!