MySQL window functions can be used to calculate daily averages or moving averages for a 24h time window relatively easily. In an earlier article
basic window functions were already discussed. In this article, we want to see how we can get daily buckets and moving averages.
A sample program is available, as usual, on GitHub
.
We will be working with a data table named data,
with three columns: a sensor id, a measurement
datetime d and a metric value m that
was sampled at that time. The table definition looks like this: …