MODULO
All functions > MATH > MODULO
Returns the remainder after dividing the first number by the second (modulo operation).
Syntax
MODULO(dividend: T, divisor: T) → T
sql
Type Parameters:
T
: BIGINT or DECIMAL
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
dividend | T | Yes | Number to be divided |
divisor | T | Yes | Number to divide by (modulus) |
Returns
Same as input type - BIGINT or DECIMAL
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