Modulo
Returns the remainder after division of the left numeric operand by the right numeric operand.
Category: binary
SQL symbol: %
Syntax
sql
<dividend> % <divisor>Parameters
<dividend>— The value to divide. Its sign is the sign of the result. Acceptsfloat,integer.<divisor>— The value to divide by. Acceptsinteger.
Returns
Examples
sql
SELECT 7 % 2, -7 % 2, 7 % -2;1 | -1 | 1
Signatures
float % integer→ floatinteger % integer→ integer
Notes
The remainder takes the sign of the DIVIDEND, not the divisor: -7 % 2 is -1 and 7 % -2 is 1. That is C and Go's rule, not Python's, where -7 % 2 is 1.