PostgreSQL/Math Functions/mod
mod(x, y): Returns the remainder (modulus) when dividing x / y
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=#
mod(y, x) remainder of y/x
postgres=# -- mod(y, x) remainder of y/x
postgres=# select mod(9,4);
mod
-----
1
(1 row)
postgres=#