Sum two single query results

I have two queries on two Influx (1.8) databases:

SELECT mean(“DayPV_kWh”) FROM “Summary_Data_INF”.“summaries” WHERE time >= now() - 30d and time <= now() GROUP BY time(2h) fill(null)

and

SELECT mean(“value”) FROM “autogen”.“total_exported_today_kwh_today” WHERE time >= now() - 30d and time <= now() GROUP BY time(2h) fill(null)

They both produce a single value for the selected time period.

What I want is the difference between the two results so I can show the value in a Grafana panel.

I have done selects in MySQL to do this but InfluxQL seems to be more restricted.

I did consider running a Python app on a daily basis which created a table where the measurement was the difference.

Can anyone see a simple way to do this?

How about doing this in Grafana? These two series are different by exactly 5

2 Likes