< [less]

All functions > COMPARISON > < [less]

Returns TRUE if the first value is strictly less than the second value

Syntax

expr1 < expr2

Function form

Returns: TRUE or FALSE according to the comparison, or NULL if either operand is NULL

LESS_THAN(expr1: T, expr2: T, [digits: BIGINT]) → BOOLEAN
sql
ParameterTypeRequiredDescription
expr1TYesFirst value to compare
expr2TYesSecond value to compare
digitsBIGINTNoDigits of rounded FLOAT/DOUBLE precision (.N); not applied when Inf or magnitude overflows DECIMAL(38, N) staging

Notes

  • Both values must be of comparable types
  • NULL comparisons always return NULL (three-valued logic)
  • For strings, uses lexicographic (dictionary) ordering
  • For dates/timestamps, earlier dates are "less than" later dates
  • For ARRAY and ROW, ordering is lexicographic / field-by-field when types align
  • Nested NULL in either ARRAY/ROW operand makes the comparison NULL (no early-exit past a poisoned field/element)
  • On FLOAT/DOUBLE, write .N (e.g. >.2, =.4, BETWEEN.3) for N decimal places of rounded precision via DECIMAL(38, N) staging, not N significant digits. Omitting .N uses 15 decimal places (DECIMAL(38, 15))
  • IN.N is 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 — .N rounding is not applied on that path
  • ORDER BY uses a separate total sort order; do not assume it matches < when NULLs are present

Examples

‹ — typical comparisons

FeatureQL
RETURN
    -- Numeric strict order
    f1 := 1 < 2,
    -- Lexicographic strings
    f2 := 'apple' < 'banana',
    -- Dates
    f3 := DATE '2024-01-01' < DATE '2024-06-01'
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEAN
truetruetrue

‹ — arrays and rows

FeatureQL
RETURN
    -- Lexicographic; first difference decides
    f1 := ARRAY(1, 2, 3) < ARRAY(1., 2., 4.),
    -- Shorter prefix can be less when shared elements match
    f2 := ARRAY(1, 2) < ARRAY(1., 2., 3.),
    -- Row field-by-field; integer/decimal may align per field
    f3 := ROW(1 AS a) < ROW(2. AS a)
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEAN
truetruetrue

‹ — three-valued logic

FeatureQL
RETURN
    -- NULL on the left
    f1 := NULL::BIGINT < 1,
    -- NULL on the right
    f2 := 1 < NULL::BIGINT,
    -- Nested NULL: no lexicographic early-exit
    f3 := ROW(1::BIGINT, NULL::BIGINT) < ROW(2::BIGINT, 0::BIGINT)
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEAN
NULLNULLNULL

LESS_THAN — functional call

FeatureQL
RETURN
    -- `LESS_THAN(expr1, expr2)` matches infix `<`
    f1 := LESS_THAN(1, 2),
    -- False when the first value is not less
    f2 := LESS_THAN(2, 1)
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse

LESS_THAN — chained

FeatureQL
RETURN
    -- Dot form: receiver is the left-hand operand
    f1 := (1).LESS_THAN(2),
    -- Same semantics as the prefix call
    f2 := (2).LESS_THAN(1)
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse