PostgreSQL MOD() function
MOD() function
The PostgreSQL mod() function is used to return the remainder of a division of two numbers, as specified in the argument.
Uses of MOD() Function
- Finding Remainders: To calculate the remainder of a division operation between two numbers.
 - Mathematical Operations: Useful in various mathematical computations involving modular arithmetic.
 - Even/Odd Determination: To determine if a number is even or odd by checking the remainder when divided by 2.
 - Cyclic Patterns: To identify repeating cycles in data or processes, such as periodic events.
 - Range Constraining: To constrain values within a specific range, often in array indexing and circular buffers.
 
Syntax:
mod()
PostgreSQL Version: 9.3
Pictorial presentation of PostgreSQL MOD() function

Example: PostgreSQL MOD() function
Code:
SELECT MOD(38,5) AS "Remainder";
Sample Output:
 Remainder
-----------
         3
(1 row)
Example: PostgreSQL MOD() function using negative value
Code:
SELECT MOD(-38,5) AS "Remainder";
Sample Output:
 Remainder
-----------
        -3
(1 row)
Previous: LOG function
Next:  PI function
