Using built-in features. I'd take a look at the window and group by recipes. You will likely have to create a window key by rounding your timestamp to the nearest hour to do this.
You may also want to look at the Time Series Preparation Plugin. This will have to be installed in your DSS instances before you can do this. In particular, you may be interested in the resampling portion of this plugin.
The overview of the Time Series Preparation Plugin can be found here.