MODULO
All functions > MATH > MODULO
Returns the remainder after dividing the first number by the second (modulo operation).
Signatures
Returns: the remainder of the division
MODULO(dividend: T, divisor: T) → T sql
| Parameter | Type | Required | Description |
|---|---|---|---|
dividend | T | Yes | Number to be divided |
divisor | T | Yes | Number to divide by (modulus) |
Notes
- Returns the remainder of integer division
- Sign of result matches the sign of the dividend
- Returns NULL if either operand is NULL
- Operator form:
dividend % divisor - Division by zero results in an error
- Useful for cycling through values, checking even/odd, etc.
Aliases
MOD
See also
Examples
FeatureQL
SELECT
f1 := MODULO(10, 3), -- Basic modulo
f2 := MODULO(15, 4), -- Another remainder
f3 := MODULO(7, 7), -- No remainder
f4 := MODULO(-10, 3), -- Negative dividend
f5 := MODULO(8, 2) -- Even number check
;Result
| f1 BIGINT | f2 BIGINT | f3 BIGINT | f4 BIGINT | f5 BIGINT |
|---|---|---|---|---|
| 1 | 3 | 0 | -1 | 0 |
On this page