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
| Parameter | Type | Required | Description |
|---|---|---|---|
expr | T | Yes | Value to test |
lower | T | Yes | Lower bound (inclusive) |
upper | T | Yes | Upper bound (inclusive) |
digits | BIGINT | No | Optional 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 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |
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 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |