between predicate (Databricks SQL)

Tests whether expr1 is greater or equal than expr2 and less than or equal to expr3.

Syntax

expr1 [not] between expr2 and expr2

Arguments

  • expr1: An expression of any comparable type.

  • expr2: An expression that shares a least common type with all other arguments.

  • expr3: An expression that shares a least common type with all other arguments.

Returns

The results is a BOOLEAN.

If not is specified the function is a synonym for expr1 < expr2 or expr1 > expr3.

Without not the function is a synonym for expr1 >= expr2 and expr1 <= expr3.

Examples

> SELECT 4 between 3 and 5;
 true
> SELECT 4 not between 3 and 5;
 false
> SELECT 4 not between NULL and 5;
  NULL