PostgreSQL/Math Functions/mod
mod(x, y): Returns the remainder (modulus) when dividing x / y
<source lang="sql">
postgres=# postgres=# -- mod(x, y): Returns the remainder (modulus) when dividing x / y postgres=# SELECT mod(5, 5) AS no_remainder, postgres-# mod(6, 5) AS remainder_one, postgres-# mod(19, 5) AS remainder_four;
no_remainder | remainder_one | remainder_four
+---------------+----------------
0 | 1 | 4
(1 row) postgres=#
</source>
mod(y, x) remainder of y/x
<source lang="sql">
postgres=# -- mod(y, x) remainder of y/x postgres=# select mod(9,4);
mod
1
(1 row) postgres=#
</source>