influxdata / influxdata/influxdb

Divide result of one query by result of another query / CASE WHEN type functionality

Open
#5,383 8 comments 48 reactions 0 assignees View on GitHub
1.x area/influxql flux/triaged
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:

![image](https://cloud.githubusercontent.com/assets/11955301/12380182/51e27dec-bd21-11e5-9c1e-1c035be207c7.png)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.