influxdata / influxdata/influxdb
Divide result of one query by result of another query / CASE WHEN type functionality
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
Hi there
I realise this is probably trivial to do, but I've searched the docs / GitHub issues and could not find a solution.
I would like to divide the result of one query by the result of another. I am using Grafana on top of InfluxDB, and would like to establish how many rows of data are within a certain target range.
Essentially, dividing the result from the top query by the result from the bottom query:

An alternative would be something like the following in T-SQL:
`SELECT sum(CASE WHEN value < 25 THEN 1 ELSE 0 END) / count(value) from "ui.thread_switch" where $timeFilter`
Does such CASE WHEN type functionality exist in InfluxDB?
I feel like this should be possible but I'm not sure how. Please could someone point me in the right direction :)? That'd be much appreciated!
Thanks,
Gaurav
Contributor guide
Research direction
The issue names no repository files, tests, or entry points. Start by reviewing the InfluxDB query functionality related to dividing query results and CASE WHEN expressions, using the Grafana and T-SQL examples in the report. Done means establishing whether the requested behavior is supported and, if not, defining the required scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100