bunny
bunny

Reputation: 115

Subtract two count values with different where clause in influxDb

I have a measurement in influxDb with two keys: operation and count. The operation key can store two different values: 'add' and 'delete'.

I want to subtract the sum(count) value when operation='delete' to sum(count) value when operation='add'.

The following query is supported in mysql but it throws and error in influxql:

select (select sum(count) from measurement where operation='add') - (select sum(count) from measurement where operation='delete');

How can this be done using a single influxql query ? I don't think influxql allows two different where clauses in this case.

Upvotes: 0

Views: 769

Answers (1)

Jan Garaj
Jan Garaj

Reputation: 28646

InfluxQL doesn't support this kind of multiquery math. You will need to calculate it on the app level.

Upvotes: 1

Related Questions