NOT BETWEEN
All functions > COMPARISON > NOT BETWEEN
Returns TRUE if a value is NOT within a specified range (inclusive).
Syntax
expr NOT BETWEEN lower AND upper
Function form
Returns: TRUE if expr lies in the inclusive range, or NULL if any argument is NULL
NOT_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 | Digits of rounded FLOAT/DOUBLE precision (.N); not applied when Inf or magnitude overflows DECIMAL(38, N) staging |
Notes
- Returns TRUE if expr < lower OR expr > upper
- Range is inclusive of both bounds
- NULL comparisons return NULL (three-valued logic)
- Opposite of BETWEEN
- All values must be of comparable types
- For strings, uses lexicographic (dictionary) ordering
- For dates, compares chronologically
- For ARRAY and ROW, same ordering rules as BETWEEN
- On FLOAT/DOUBLE, write
.N(e.g.>.2,=.4,BETWEEN.3) for N decimal places of rounded precision viaDECIMAL(38, N)staging, not N significant digits. Omitting.Nuses 15 decimal places (DECIMAL(38, 15)) IN.Nis the same suffix on membership- Any NaN operand makes the comparison NULL
- Infinity, or any finite value too large for
DECIMAL(38, N), falls back to a raw float compare —.Nrounding is not applied on that path
Examples
NOT BETWEEN — outside inclusive band
FeatureQL
RETURN
-- Below lower bound
f1 := 0 NOT BETWEEN 1 AND 5,
-- Above upper bound
f2 := 10 NOT BETWEEN 1 AND 5,
-- Inside range is false
f3 := 3 NOT BETWEEN 1 AND 5
;Result
| f1 BOOLEAN | f2 BOOLEAN | f3 BOOLEAN |
|---|---|---|
| true | true | false |
NOT BETWEEN — arrays and rows
FeatureQL
RETURN
-- Below the lower bound in lexicographic order
f1 := ARRAY(0, 0) NOT BETWEEN ARRAY(1, 1) AND ARRAY(3, 3)
;Result
| f1 BOOLEAN |
|---|
| true |
NOT BETWEEN — NULL
FeatureQL
RETURN
-- NULL value
f1 := NULL::BIGINT NOT BETWEEN 1 AND 10
;Result
| f1 BOOLEAN |
|---|
| NULL |
NOT_BETWEEN — functional call
FeatureQL
RETURN
-- `NOT_BETWEEN(expr, lower, upper)` matches keyword `NOT BETWEEN … AND …`
f1 := NOT_BETWEEN(10, 1, 5),
-- Inside the inclusive range
f2 := NOT_BETWEEN(3, 1, 5)
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |
NOT_BETWEEN — chained
FeatureQL
RETURN
-- Receiver is the value; arguments are lower and upper bounds
f1 := (10).NOT_BETWEEN(1, 5),
-- Same semantics as the prefix call
f2 := (3).NOT_BETWEEN(1, 5)
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |