Group DateTime into 5,15,30 and 60 minute intervals
问题 I am trying to group some records into 5-, 15-, 30- and 60-minute intervals: SELECT AVG(value) as "AvgValue", sample_date/(5*60) as "TimeFive" FROM DATA WHERE id = 123 AND sample_date >= 3/21/2012 i want to run several queries, each would group my average values into the desired time increments. So the 5-min query would return results like this: AvgValue TimeFive 6.90 1995-01-01 00:05:00 7.15 1995-01-01 00:10:00 8.25 1995-01-01 00:15:00 The 30-min query would result in this: AvgValue