Tabular IQ
Back to Function Index

MOD()

Overview

MOD() calculates the remainder after division of one number by another. This function is useful for cyclic calculations, determining even/odd numbers, and handling periodic patterns in data. It's equivalent to the modulo operator (%) in many programming languages.

Function Format

MOD(numerator, denominator)

Return Value

MOD() returns a numeric value

Examples


MOD(9, 3) = 0                    (exact division, no remainder)
MOD(10, 3) = 1                   (remainder of 1)
MOD(-10, 3) = -1                 (negative numerator)
MOD(10.2, 3) = 1.2               (decimal values)
MOD(5, 2) = 1                    (odd number check)
MOD(6, 2) = 0                    (even number check)
MOD(0, 5) = 0                    (zero numerator)
MOD(5, 0) = Error                (division by zero)
MOD(NULL, 5) = NULL              (NULL handling)

Notes

  • Important behaviors:
    • Returns the remainder after division
    • Works with both integer and decimal values
    • Preserves the sign of the numerator
    • Returns NULL if either input is NULL
    • Throws an error for division by zero
  • Common use cases include:
    • Determining even/odd numbers
    • Cyclic calculations
    • Periodic patterns
    • Data grouping
    • Time calculations
  • The function can be used with:
    • Integer values
    • Decimal values
    • Numeric expressions
    • Column values
  • This function is often used in combination with other mathematical functions for complex calculations.
  • For integer division without remainder, use the DIV() function.

See Also