'InfluxDB select aggregate value and tag as string, grouped by tag

I am using an InfluxDB data source in Grafana. I have a repeating panel of graphs, grouped by a tag value. I am wishing to sort these graphs by an aggregate numeric value, rather than the tag value itself. A trivial InfluxDB query would be:

SELECT sum(value) FROM "application__request-count" GROUP BY method
value method
123 first
234 second

This would be fine, however Grafana variables only appear to work with a single field. I am therefore looking to concatenate the aggregate value and the tag then split them apart in Grafana itself. Something closer to:

value
123|first
234|second

I naively tried:

SELECT sum(value) + "|" + method FROM "application__request-count" GROUP BY method

However I receive the InfluxDB error: "binary expressions cannot mix aggregates and raw fields"

Is there a way to do what I'm looking for in Influx?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source