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 addYou can add together other field keys.
SELECT A + B FROM addSubtraction
You can subtract a constant.
SELECT 1 - A FROM subYou can subtract one field key from another field key.
SELECT A - B FROM subMultiplication
You can multiply by a constant.
SELECT 10 * A FROM multYou can multiply by other field keys.
SELECT A * B * C FROM multMultiplication 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 divYou can divide by other field keys.
SELECT A / B FROM divDivision 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.
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.