Important
The SingleStore 9.1 release candidate (RC) is available now. It will be promoted to general availability (GA) soon and at that time it will be renamed to SingleStore 10.
In the interim, SingleStore 9.1 RC can be used to preview, evaluate, and provide feedback on the new and upcoming features in SingleStore 10, while SingleStore 9.0 is recommended for production workloads.
MOD
On this page
MOD stands for Modulo.MOD() function calculates the remainder of a number divided by another number.
Syntax
MOD (expression1 , expression2)expression1 MOD expression2expression1 `%` expression2
Arguments
-
expression1,expression2: Any numerical expression.This could be a column name, the result of another function, or a math operation. -
expression1: dividend.A value that will be divided by expression2. -
expression2: divisor.
Return Type
A decimal if the input is decimal, otherwise integer.
Remarks
Returns NULL if the divisor is 0 or either of the arguments is a NULL.
Examples
The following queries return the remainder.
SELECT MOD (84,5);
+------------------------------+
| mod (84,5) |
+------------------------------+
| 4 |
+------------------------------+
1 row in set (899 ms)SELECT 12 MOD 5;
+------------------------------+
| 12 MOD 5 |
+------------------------------+
| 2 |
+------------------------------+
1 row in set (346 ms)The following query returns NULL as the divisor is 0.
SELECT 25 % 0;
+------------------------------+
| 25 % 0 |
+------------------------------+
| NULL |
+------------------------------+
1 row in set (341 ms)Last modified: