I’m trying to come up with a query that’s similar to the InfluxDB Difference function, except that rather than calculating the difference between subsequent field values, it would calculate the difference with respect to a specific field value.
I’m using InfluxDB to store performance test statistics, and I’d like to see the difference of each Response Time value with respect to a baseline Response Time value.
Say I had a measurement consisting of the 2 fields, “Date” and “Resp Time”, and the data looks like this:
| Date | Resp Time |
| 1/1/2019 | 4 |
| 1/2/2019 | 7 |
| 1/3/2019 | 3 |
| 1/4/2019 | 9 |
| 1/5/2019 | 2 |
The 1/3/2019 row contains the Resp Time value that I’d like to compare each of the other Resp Time values to.
I would like an output that looks something like this:
| Date | Resp Time | | Difference |
| 1/1/2019 | 4 | | 1 |
| 1/2/2019 | 7 | | 4 |
| 1/3/2019 | 3 | | 0 |
| 1/4/2019 | 9 | | 6 |
| 1/5/2019 | 2 | | -1 |
I was thinking of a query like this but I don’t think I can reference different table aliases in the Select portion of an InfluxDB query:
SELECT t1.Date, t1.RespTime, t1.RespTime-t2.RespTime AS Difference
FROM Table1 AS t1, Table1 AS t2
Any thoughts would be much appreciated.