# Sum two single query results

**URL:** https://community.influxdata.com/t/sum-two-single-query-results/29231
**Category:** InfluxQL
**Tags:** influxdb, influxql
**Created:** [March 26, 2023, 5:31pm UTC](https://community.influxdata.com/t/sum-two-single-query-results/29231 "2023-03-26T17:31:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dgoadby](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@dgoadby](https://community.influxdata.com/u/dgoadby)
#### Post date: [March 26, 2023, 5:31pm UTC](https://community.influxdata.com/t/sum-two-single-query-results/29231/1 "2023-03-26T17:31:34Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![grant1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grant1/32/15107_2.png) [@grant1](https://community.influxdata.com/u/grant1)
#### Post date: [March 26, 2023, 6:15pm UTC](https://community.influxdata.com/t/sum-two-single-query-results/29231/2 "2023-03-26T18:15:13Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/4/4f7eb1f6e20991c2a8cfdca9b35d5574b27fdfa7.png)
