PMOD
Descriptionβ
Returns the smallest positive solution of the modulo operation x mod y within the modular system, which is obtained by calculating (x % y + y) % y.
Syntaxβ
PMOD(<x> , <y>)
Parametersβ
Parameter | Description |
---|---|
<x> | Dividend |
<y> | Divisor should not be 0 |
Return valueβ
Returns an integer or a floating-point number. Special cases:
- If x = 0, returns 0.
- If x is NULL or y is NULL, returns NULL.
Exampleβ
SELECT PMOD(13,5);
+-------------+
| pmod(13, 5) |
+-------------+
| 3 |
+-------------+
SELECT PMOD(-13,5);
+--------------+
| pmod(-13, 5) |
+--------------+
| 2 |
+--------------+
SELECT PMOD(0,-12);
+--------------+
| pmod(0, -12) |
+--------------+
| 0 |
+--------------+
SELECT PMOD(0,null);
+-------------------------------+
| pmod(cast(0 as DOUBLE), NULL) |
+-------------------------------+
| NULL |
+-------------------------------+