我有以下简单表:1 Z( V1 N O" p4 x$ d. ^
ID TIMESTAMP VALUE4 2011-05-27 15:004 12535 -05-27 15:55:02 13046 -05-27 16:002 1327 -05-27 16:05:01 1364我想了平均VALUES,并且GROUP每TIMESTAMP一天6小时桶。比如00:00到06:00,06:00到12:00,12:00到18:00,18:00到00:00。" }- e e& O A+ N5 e9 d! }/ F# B& g
按年、月、日、小时使用以下查询: 5 N( S" o% j% `/ [* r! Xselect avg(VALUE), EXTRACT(year from TIMESTAMP) AS year, EXTRACT(month from TIMESTAMP) AS month, EXTRACT(day from TIMESTAMP) as day from TABLE group by year,month,day但我不能每天分为以上四个时间段,非常欢迎您提供任何帮助。6 V. `3 V2 }+ a: A