BETWEEN
All functions > COMPARISON > BETWEEN
Returns TRUE if a value is within a specified range (inclusive)
Signatures
Returns: TRUE if expr is within the range, FALSE otherwise, NULL if any value is NULL
BETWEEN(expr: T, lower: T, upper: T, [digits: BIGINT]) → BOOLEAN sql
| Parameter | Type | Required | Description |
|---|---|---|---|
expr | T | Yes | Expression to test |
lower | T | Yes | Minimum value of the range (inclusive) |
upper | T | Yes | Maximum value of the range (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
- Supports optional decimal precision for numeric comparisons
See also
On this page