我有以下表结构,每天每小时的数据:
time_of_ocurrence(timestamp); particles(numeric)
"2012-11-01 00:30:00";191.3
"2012-11-01 01:30:00";46
...
"2013-01-01 02:30:00";319.6
如何选择DAILY 最大值和该最大值出现的 HOUR?我试过了
SELECT date_trunc('hour', time_of_ocurrence) as hora,
MAX(particles)
from my_table WHERE time_of_ocurrence > '2013-09-01'
GROUP BY hora ORDER BY hora
但它不起作用:
"2013-09-01 00:00:00";34.35
"2013-09-01 01:00:00";33.13
"2013-09-01 02:00:00";33.09
"2013-09-01 03:00:00";28.08
我的结果将采用这种格式(每天最多一个,显示小时)
"2013-09-01 05:00:00";100.35
"2013-09-02 03:30:00";80.13
我怎样才能做到这一点?谢谢!