Subquery to calculate sum of same field multiple time of same Measurement for InfluxDB datasource

Hi,

I was writing a subquery to calculate multiple sum with different condition for a field. But it is resulting only sum of first. Below is my query and please help me to solve this issue.

SELECT sum(“txn_41”), sum(“txn_42”) from (SELECT “txn_id” as “txn_41” from “measurement1” where “level”=‘41’), (SELECT “txn_id” as “txn_42” from “measurement1” where “level”=‘42’)

Any Ideas and explanations are welcome or any other way round to achieve the result.

//Warm Regards,
Ashlesh Mandke

Not sure Influxdb supports what your trying to do. Are there any examples like this in the influxdb query docs?

Actually I want to subtract on two different columns such as:-
if level - 1 sum(txn_id) is 40 and level -2 sum(txn_id) is 30 result should be 10

In sql we have query as:-
select (select sum(txn_id) from m1 where level=41)-(select sum(txn_id) from m1 where level=42) as txn_diff

And I have noticed that two same aggregation function does not work on same field. It is resulting only sum of first.
Is this possible in Influxdb and grafana or any alternative to above issue.

should we recommend this as a feature request on the GitHub ?