Skip to content
Advertisement

Calculating a 7 day average

I have this query.

I want to generate the 7 day average of the mappings column. For example, I want to calculate the average mappings for each day (from 2020-01-03 – 2020-01-10).

Results:

Then return avg(avg_mapping)

Advertisement

Answer

I don’t see how your question relates to a rolling average. From your data and results, it seems like you just want aggregation and avg():

If you want the average of column avg_mapping in the resultset (which is not the same thing as an overall average of mapping), then you can add another level of aggregation:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement