日期:2014-05-17  浏览次数:20749 次

怎么得到每小时内的最大值、最小值和平均值
本帖最后由 charlesxu 于 2013-11-13 10:34:21 编辑
数据表如下:
        time                           value
1       2013-11-13 09:00        1.00
2       2013-11-13 08:30        2.00
3       2013-11-13 08:00        3.00
4       2013-11-13 07:30        4.00
5       2013-11-13 07:00        5.00
6       2013-11-13 06:30        6.00
7       2013-11-13 06:00        7.00
8       2013-11-13 05:30        8.00
9       2013-11-13 05:00        9.00
10      2013-11-13 04:30        10.00
11      2013-11-13 04:00        11.00


探头每半小时收集一次值,我怎么取到每小时的最大值、最小值和平均值?

我想得到的查询结果是

TIME                    MAX     MIN    AVG
2013-11-13 09:00        1.00     1     1
2013-11-13 08:00        3.00     2     (3+2)/2
2013-11-13 07:00        5.00     4     (5+4)/2
2013-11-13 06:00        7.00     6     (7+6)/2
2013-11-13 05:00        9.00     8     (9+8)/2
2013-11-13 04:00        11.00    10    (11+10)/2

------解决方案--------------------
select to_char(time,'yyyymmdd hh24')
------解决方案--------------------
':00',max(value),min(value),avg(value) from A group by to_char(time,'yyyymmdd hh24')

------解决方案--------------------
引用:
select to_char(time,'yyyymmdd hh24')
------解决方案--------------------
':00',max(value),min(value),avg(value) from A group by to_char(time,'yyyymmdd hh24')

+1
---