Using InfluxDB subquery to subtract values : <p>I have a Influx database that is getting filled with values. These values are presented by Grafana. What I need is to get the actual values depending on the selected time interval.</p>

<p>Currently I have the following query for a single metric:</p>

<pre><code>SELECT mean("value") FROM "table" WHERE $timeFilter GROUP BY time($interval) fill(null)
</code></pre>

<p>What I want is to subtract the lowest value from that interval, so it only counts the values from within that interval. So the graph needs to start at zero. To get the lowest value from that interval I use:</p>

<pre><code>SELECT min("value") FROM "table" WHERE $timeFilter 
</code></pre>

<p>So I thought combining those two (with a subquery) like this should work:</p>

<pre><code>SELECT mean("value") - (SELECT min("value") FROM "table" WHERE $timeFilter) FROM "table" WHERE $timeFilter GROUP BY time($interval) fill(null)
</code></pre>

<p>Unfortunately this doesnt work. The query is not accepted as a subquery.</p>
