Documentation

SQL conditional functions

Limited availability

InfluxDB Clustered is currently only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

The InfluxDB SQL implementation supports the following conditional functions for conditionally handling null values:

coalesce

Returns the first of its arguments that is not null. Returns null if all arguments are null. This function is often used to substitute a default value for null values.

coalesce(expression1[, ..., expression_n])
Arguments
  • expression1, expression_n: Expression to use if previous expressions are null. Can be a constant, column, or function, and any combination of arithmetic operators. Pass as many expression arguments as necessary.

View coalesce query example

ifnull

Alias of nvl.

nullif

Returns null if expression1 equals expression2; otherwise it returns expression1. This can be used to perform the inverse operation of coalesce.

nullif(expression1, expression2)
Arguments
  • expression1: Expression to compare and return if equal to expression2. Can be a constant, column, or function, and any combination of arithmetic operators.
  • expression2: Expression to compare to expression1. Can be a constant, column, or function, and any combination of arithmetic operators.

View nullif query example

nvl

Returns expression2 if expression1 is null; otherwise it returns expression1.

nvl(expression1, expression2)
Arguments
  • expression1: Return this expression if not null. Can be a constant, column, or function, and any combination of arithmetic operators.
  • expression2: Return this expression if expression1 is null. Can be a constant, column, or function, and any combination of arithmetic operators.

View nvl 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.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following: