SQL MOD is a deterministic arithmetic function that calculates the remainder of an integer or exact numeric division. The dividend is divided by the divisor, and only the leftover part is returned. Most engines support it as a function (MOD(dividend, divisor)); some also expose the percent sign (%) operator as shorthand. The result carries the same sign as the dividend in ANSI-compliant systems, though a few legacy engines mirror the sign of the divisor. Division by zero raises an error. When either argument is NULL, the function returns NULL. If inputs are non-integer numerics, many systems truncate them to integers before performing the division.
dividend
(Numeric) - The value to be divided.divisor
(Numeric) - The value that divides the dividend. Must not be zero.% operator, FLOOR(), CEIL(), ABS(), DIV, arithmetic operators
SQL:1999
Any exact numeric type (INTEGER, BIGINT, NUMERIC, DECIMAL). Floating types are accepted in some engines but are implicitly converted to integers.
ANSI-compliant engines give the result the same sign as the dividend. Verify engine-specific behavior if sign matters.
Most optimizers treat MOD() and % identically, so performance is the same. Use whichever style matches team conventions.
Because MOD alters the value, indexes on the original column are not used directly. Consider computed columns or partial indexes if performance is critical.