MODULO()

All functions > MATH > MODULO()

Returns the remainder after dividing the first number by the second.

Signatures

Modulo

Returns: Remainder of the division

MODULO(dividend: T, divisor: T) → T
sql
ParameterTypeRequiredDescription
dividendTYesNumber to be divided
divisorTYesNumber to divide by

With:

  • T : Custom types: TINYINT | SMALLINT | INT | BIGINT | DECIMAL

Signature notes:

  • Both arguments must be of the same type (integer or DECIMAL)
  • Sign of the result matches the sign of the dividend
  • Returns NULL if either operand is NULL
  • Division by zero raises an error

Aliases

  • MOD

Related operators

Examples

MODULO(...)

FeatureQL
SELECT
    f1 := MODULO(10, 3) -- Function call
;
Result
f1 BIGINT
1

.MODULO(...) — chained

FeatureQL
SELECT
    f1 := (10).MODULO(3), -- Integer literal: parenthesize for `.MODULO` on BIGINT
    f2 := 10.0.MODULO(3) -- Decimal base: chain without extra parentheses
;
Result
f1 BIGINTf2 VARCHAR
11.0

Edge cases

FeatureQL
SELECT
    f1 := MODULO(15, 4), -- Another remainder
    f2 := MODULO(7, 7), -- No remainder
    f3 := MODULO(-10, 3) -- Negative dividend
;
Result
f1 BIGINTf2 BIGINTf3 BIGINT
30-1

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