Help me with Query

Hello,

I need help in influx query.
Here my measurement looks like.

Measurement : Transaction

|Time|StartValue|EndValue|Name|
|Some Time|12121|22112|Transaction01|
|Some Time|3331|4444|Transaction01|
|Some Time|5459|13224|Transaction02|
|Some Time|14249|30892|Transaction02|
|Some Time|23039|48560|Transaction02|

Expected Output as Table

|Mean(EndValue-StartValue)|Name|
|5552|Transaction01|
|16643|Transaction02|

I would like to get mean((“EndValue”-“StartValue”)) from “Transactions” group by “Name”.
But mean() function is not working and not showing as expecting.
Here is the my measurement

I really appreciate your help.

Thanks,
Naresh

@nareshnakka What version of InfluxDB are you using? Are you hoping for an InfluxQL query or a Flux query?

Scott,

Influx version : 1.8.4.
I am expecting a query. I tried but did nt give an expected result.
I am integrating influx with Grafana. As part of table visualizartion im trying to get the mentioned output.

Ok, so you’re using InfluxQL then. My InfluxQL is a little rusty, but I would think the following would work:

SELECT mean("EndValue" - "StartValue") AS "Mean(EndValue-StartValue)" FROM "Transaction" GROUP BY "Name"

Got Error : error:“expected field argument in mean()”

For your reference Here is the Screenshots:

  1. Select the respective Fields :
    influxErrors/Screenshot1.PNG at main · nareshnakka/influxErrors · GitHub

  2. Query output given by you, errored :
    influxErrors/Capture2.PNG at main · nareshnakka/influxErrors · GitHub

Can someone help me on this ?