Which function in SQL is used to find remainder of one number divided by another?

The MOD() function in SQL is used to find the remainder of one number divided by another. The MOD() function returns the remainder of dividend divided by divisor. if the divisor is zero, it returns NULL.

Syntax :

MOD(N, M) 
or 
N % M 
or 
N MOD M

Parameter : MOD() function accepts two parameter as mentioned above and described below.

  • N –The dividend i.e. a number or a numeric expression that will be divided by M.
  • M –The divisor i.e. a number or a numeric expression by which to divide the dividend.

Returns : It returns the remainder of dividend divided by divisor.

Example:

Finding the remainder of 36 when it is divided by 6 using MOD Function.

SELECT MOD( 36, 6) 
AS Remainder;

Output :

Remainder

0