Integral for averaging random interval temperature data

I’m new to Influxdb (or any DB really). I have various temperature data collected with unequal time intervals.

I want the average temperature for each day. I can’t use mean(“value”), as it won’t reflect the duration of each temperature point.

So the obvious route to me is to use the Integral to find the area under the curve, then divide by the number of time intervals used for the integration. I can achieve this relatively easily.

The problem I have is that due to the fact that I can’t use the fill functions to join the gaps caused by any missing data, I am concerned that if for some reason there are gaps or null values, the query may return an incorrect average and I won’t be aware of the fact.

Any ideas on overcoming this, or an alternative to Integral to find the average of random interval data?

Many thanks in advance

Hello @qwertyu,
Would the aggregateWindow() function help? aggregateWindow() function | Flux 0.x Documentation