MOD Function [Numeric]

Returns the remainder when one whole number is divided by another.

Syntax

MODdividend, divisor )

Parameters

Parameters

Description

dividend

The dividend, or numerator of the division.

divisor

The divisor, or denominator of the division.

Returns

SMALLINT

INT

NUMERIC

Example

The following statement returns the value 2:

SELECT MOD( 5, 3 ) FROM iq_dummy

Usage

Division involving a negative dividend gives a negative or zero result. The sign of the divisor has no effect.

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Not supported in Adaptive Server Enterprise. The % operator is used as a modulo operator in Adaptive Server Enterprise.

Related reference
REMAINDER Function [Numeric]