Documentation

SQL math functions

The InfluxDB Cloud Dedicated SQL implementation supports the following math functions for performing mathematic operations:

abs

Returns the absolute value of a number.

abs(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View abs query example

acos

Returns the arc cosine or inverse cosine of a number.

acos(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View acos query example

acosh

Returns the area hyperbolic cosine or inverse hyperbolic cosine of a number.

acosh(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View acosh query example

asin

Returns the arc sine or inverse sine of a number.

asin(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View asin query example

asinh

Returns the area hyperbolic sine or inverse hyperbolic sine of a number.

asinh(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View asinh query example

atan

Returns the arc tangent or inverse tangent of a number.

atan(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View atan query example

atanh

Returns the area hyperbolic tangent or inverse hyperbolic tangent of a number.

atanh(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View atanh query example

atan2

Returns the arc tangent or inverse tangent of expression_y / expression_x.

atan2(expression_y, expression_x)
  • Copy
  • Fill window
Arguments
  • expression_y: First numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
  • expression_x: Second numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View atan2 query example

cbrt

Returns the cube root of a number.

cbrt(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View cbrt query example

ceil

Returns the nearest integer greater than or equal to a number.

ceil(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View ceil query example

cos

Returns the cosine of a number.

cos(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View cos query example

cosh

Returns the hyperbolic cosine of a number.

cosh(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View cosh query example

cot

Returns the cotangent of a number.

cot(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of operators.

View cot query example

degrees

Converts radians to degrees.

degrees(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View degrees query example

exp

Returns the base-e exponential of a number.

exp(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to use as the exponent. Can be a constant, column, or function, and any combination of arithmetic operators.

View exp query example

factorial

Returns 1 if value is less than 2.

factorial(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Must be an integer (BIGINT). Can be a constant, column, or function, and any combination of arithmetic operators.

View factorial query example

floor

Returns the nearest integer less than or equal to a number.

floor(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View floor query example

gcd

Returns the greatest common divisor of expression_x and expression_y. Returns 0 if both inputs are zero.

gcd(expression_x, expression_y)
  • Copy
  • Fill window
Arguments
  • expression_x: First numeric expression to operate on. Must be an integer (BIGINT). Can be a constant, column, or function, and any combination of arithmetic operators.
  • expression_y: Second numeric expression to operate on. Must be an integer (BIGINT). Can be a constant, column, or function, and any combination of arithmetic operators.

View gcd query example

isnan

Returns true if a given number is ±NaN, otherwise returns false.

isnan(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Must be a float (DOUBLE). Can be a constant, column, or function, and any combination of arithmetic operators.

View isnan query example

iszero

Returns true if the given number is ±0.0, otherwise returns false.

iszero(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View iszero query example

lcm

Returns the least common multiple of expression_x and expression_y. Returns 0 if either input is zero.

lcm(expression_x, expression_y)
  • Copy
  • Fill window
Arguments
  • expression_x: First numeric expression to operate on. Must be an integer (BIGINT). Can be a constant, column, or function, and any combination of arithmetic operators.
  • expression_y: Second numeric expression to operate on. Must be an integer (BIGINT). Can be a constant, column, or function, and any combination of arithmetic operators.

View lcm query example

ln

Returns the natural logarithm of a number.

ln(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View ln query example

log

Returns the base-x logarithm of a number.

log([base, ]numeric_expression)
  • Copy
  • Fill window

Arguments

  • base: Base numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators. Default is 10.
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View log query example

log10

Returns the base-10 logarithm of a number.

log10(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View log10 query example

log2

Returns the base-2 logarithm of a number.

log2(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View log2 query example

nanvl

Returns the first argument if it’s not ±NaN. Otherwise returns the second argument.

nanvl(expression_x, expression_y)
  • Copy
  • Fill window
Arguments
  • expression_x: Numeric expression to return if it’s not NaN. Can be a constant, column, or function, and any combination of arithmetic operators.
  • expression_y: Numeric expression to return if the first expression is NaN. Can be a constant, column, or function, and any combination of arithmetic operators.

View nanvl query example

pi

Returns an approximate value of π.

pi()
  • Copy
  • Fill window

View pi query example

power

Returns a base expression raised to the power of an exponent.

power(base, exponent)
  • Copy
  • Fill window
Aliases
  • pow
Arguments
  • base: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
  • exponent: Exponent numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View power query example

pow

Alias of power.

radians

Converts degrees to radians.

radians(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View radians query example

random

Returns a random float value between 0 and 1. The random seed is unique to each row.

random()
  • Copy
  • Fill window

View random query example

round

Rounds a number to the nearest integer.

round(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View round query example

signum

Returns the sign of a number. Negative numbers return -1. Zero and positive numbers return 1.

signum(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View signum query example

sin

Returns the sine of a number.

sin(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View sin query example

sinh

Returns the hyperbolic sine of a number.

sinh(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View sinh query example

sqrt

Returns the square root of a number.

sqrt(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View sqrt query example

tan

Returns the tangent of a number.

tan(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View tan query example

tanh

Returns the hyperbolic tangent of a number.

tanh(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View tanh query example

trunc

Truncates a number toward zero (at the decimal point).

trunc(numeric_expression)
  • Copy
  • Fill window
Arguments
  • numeric_expression: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

View trunc query example


Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB 3 Core and Enterprise are now in Beta

InfluxDB 3 Core and Enterprise are now available for beta testing, available under MIT or Apache 2 license.

InfluxDB 3 Core is a high-speed, recent-data engine that collects and processes data in real-time, while persisting it to local disk or object storage. InfluxDB 3 Enterprise is a commercial product that builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries. A free tier of InfluxDB 3 Enterprise will also be available for at-home, non-commercial use for hobbyists to get the full historical time series database set of capabilities.

For more information, check out: