# How to subtract values from different queries

**URL:** <https://community.influxdata.com/t/how-to-subtract-values-from-different-queries/9787>\
**Category:** Welcome & Getting Started\
**Created:** [May 14, 2019, 9:55am UTC](https://community.influxdata.com/t/how-to-subtract-values-from-different-queries/9787 "2019-05-14T09:55:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mauog](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mauog/32/2721_2.png) [@mauog](https://community.influxdata.com/u/mauog)\
**Post date:** [May 14, 2019, 9:55am UTC](https://community.influxdata.com/t/how-to-subtract-values-from-different-queries/9787/1 "2019-05-14T09:55:07Z")

</div>

Hello,  
I would need to subtract value from different queries but I cannot figure how how to do.  
In fact any attempt done got an error 400.

Here are the queries:

```
A) select sum(wh)/1000 from (select mean_value /60 as wh from (SELECT mean(*) FROM "power"."autogen"."generale_w" WHERE time > now()-24h GROUP BY time(1m) fill(none)))

B) select sum(wh)/1000 from (select mean_value /60 as wh from (SELECT mean(*) FROM "power"."autogen"."lavatrice" WHERE time > now()-24h GROUP BY time(1m) fill(none)))
C) select sum(wh)/1000 from (select mean_value /60 as wh from (SELECT mean(*) FROM "power"."autogen"."forno" WHERE time > now()-24h GROUP BY time(1m) fill(none)))
D) select sum(wh)/1000 from (select mean_value /60 as wh from (SELECT mean(*) FROM "power"."autogen"."lavastoviglie" WHERE time > now()-24h GROUP BY time(1m) fill(none)))
E) select sum(wh)/1000 from (select mean_value /60 as wh from (SELECT mean(*) FROM "power"."autogen"."frigorifero" WHERE time > now()-24h GROUP BY time(1m) fill(none)))

```

I would need to got a value from:

**A - (B+C+D+E)**

Could You hep me please?

Thank You

Regards

---

<div class="post-metadata">

**Author:** ![sebito91](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/sebito91/32/42_2.png) [@sebito91](https://community.influxdata.com/u/sebito91)\
**Post date:** [May 14, 2019, 1:32pm UTC](https://community.influxdata.com/t/how-to-subtract-values-from-different-queries/9787/2 "2019-05-14T13:32:26Z")

</div>

Hey @mauog, this unfortunately is a limitation of the current v1.x branch of `influxdb`, but is something that a lot of people have been asking about:

> **[InfluxDB frequently asked questions | InfluxDB OSS 1.8 Documentation](https://docs.influxdata.com/influxdb/v1.7/troubleshooting/frequently-asked-questions/#how-do-i-query-data-across-measurements)**
>
> Common issues with InfluxDB OSS.

If you’re up for using the v2.0-alpha as a test, you can do this now! Check out this amazing post about doing just that:

> **[InfluxDB: How to Do Joins, Math across Measurements | Blog | InfluxData](https://www.influxdata.com/blog/influxdb-how-to-do-joins-math-across-measurements/)**
>
> InfluxData has released the technical preview of Flux, and with it comes the ability to perform math across measurements.

---

<div class="post-metadata">

**Author:** ![mauog](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mauog/32/2721_2.png) [@mauog](https://community.influxdata.com/u/mauog)\
**Post date:** [May 15, 2019, 8:02am UTC](https://community.influxdata.com/t/how-to-subtract-values-from-different-queries/9787/3 "2019-05-15T08:02:24Z")

</div>

Thanks @sebito91,  
as far as you know is there any workaround maybe using any other programs?
