Modulo

The modulo operator ( % ) divides the first operand by the second operand (the modulus) and returns the remainder.

Note: A configuration parameter is available to control whether this operator allows precision/scale to exceed 38. See Decimal Digit Limitation on Functions, for details.

Syntax

operand1 % operand2

Example

11 % 3

Eleven modulo 3 is 2; that is, 11 divided by 3 has a remainder of 2.

Remarks

The input (operand1 and operand2) data types and resulting output data types are shown in the table.

Operand1

Operand2

Output

TINYINT
SMALLINT
INTEGER
BIGINT
STRING

TINYINT
SMALLINT
INTEGER
BIGINT
STRING

INTEGER

NULL

TINYINT
SMALLINT
INTEGER
BIGINT
STRING

NULL

TINYINT
SMALLINT
INTEGER
BIGINT

NULL

NULL