BETWEEN()

All functions > COMPARISON > BETWEEN()

Returns TRUE if a value is within a specified range (inclusive)

Signatures

Returns: TRUE if expr lies in the inclusive range, or NULL if any argument is NULL

BETWEEN(expr: T, lower: T, upper: T, [digits: BIGINT]) → BOOLEAN
sql
ParameterTypeRequiredDescription
exprTYesValue to test
lowerTYesLower bound (inclusive)
upperTYesUpper bound (inclusive)
digitsBIGINTNoOptional decimal precision for numeric comparisons

Notes

  • All three values must be of comparable types
  • The range is inclusive of both bounds
  • NULL comparisons always return NULL (three-valued logic)
  • Equivalent to: value >= lower_bound AND value <= upper_bound
  • For strings, uses lexicographic (dictionary) ordering
  • For dates, compares chronologically
  • For ARRAY and ROW, uses the same ordering as < / >=
  • Supports optional decimal precision for numeric comparisons

Related operators

Examples

BETWEEN — functional call

FeatureQL
SELECT
    f1 := BETWEEN(3, 1, 5), -- `BETWEEN(expr, lower, upper)` matches keyword `BETWEEN … AND …`
    f2 := BETWEEN(0, 1, 5) -- Below the inclusive range
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse

BETWEEN — chained

FeatureQL
SELECT
    f1 := (3).BETWEEN(1, 5), -- Receiver is the value; arguments are lower and upper bounds
    f2 := (0).BETWEEN(1, 5) -- Same semantics as the prefix call
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse

Last update at: 2026/05/26 17:22:09