This is archived documentation for InfluxData product versions that are no longer maintained. For newer documentation, see the latest InfluxData documentation.
Mathematical operators follow the standard order of operations.
That is, parentheses take precedence to division and multiplication, which takes precedence to addition and substraction.
For example 5 / 2 + 3 * 2 = (5 / 2) + (3 * 2) and 5 + 2 * 3 - 2 = 5 + (2 * 3) - 2.
Supported Operators
Addition
You can add a constant.
SELECT A + 5 FROM addSELECT * FROM add WHERE A + 5 > 10You can add together other field keys.
SELECT A + B FROM addSELECT * FROM add WHERE A + B >= 10Subtraction
You can subtract a constant.
SELECT 1 - A FROM subSELECT * FROM sub WHERE 1 - A <= 3You can subtract one field key from another field key.
SELECT A - B FROM subSELECT * FROM sub WHERE A - B <= 1Multiplication
You can multiply by a constant.
SELECT 10 * A FROM multSELECT * FROM mult WHERE A * 10 >= 20You can multiply by other field keys.
SELECT A * B * C FROM multSELECT * FROM mult WHERE A * B <= 80Multiplication distributes across other operators
SELECT 10 * (A + B + C) FROM multSELECT 10 * (A - B - C) FROM multSELECT 10 * (A + B - C) FROM multDivision
You can divide by a constant.
SELECT 10 / A FROM divSELECT * FROM div WHERE A / 10 <= 2You can divide by other field keys.
SELECT A / B FROM divSELECT * FROM div WHERE A / B >= 10Division distributes across other operators
SELECT 10 / (A + B + C) FROM multOperators with Functions
The use of mathematical operators inside of function calls is currently unsupported.
Note that InfluxDB only allows functions in the SELECT clause.
For example
SELECT 10 * mean(value) FROM cpuwill work, however
SELECT mean(10 * value) FROM cpuwill yield a parse error.
Unsupported Operators
Inequalities
Using any of =,!=,<,>,<=,>=,<> in the SELECT clause yields empty results for all types.
See GitHub issue 3525.
Miscellaneous
Using any of %, ^ will yield a parse error.
If you would like to see support for these operators open an issue.
Logical Operators are Unsupported
Using any of &,|,!|,NAND,XOR,NOR will yield parse error.
Additionally using AND, OR in the SELECT clause of a query will not behave as mathematical operators and simply yield empty results, as they are tokens in InfluxQL.