Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

MOD

Example

Provide the remainder resulting from dividing 18 by 4.

SELECT MOD(18, 4); 

Definition and Usage

The MOD() function computes the remainder when dividing one number by another.

Syntax

MOD(x, y)

OR:

x MOD y

OR:

x % y

Parameter Values

Parameter

Description

x

Mandatory: A value that will undergo division by y.

y

Mandatory: The number by which the value will be divided.

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Find the remainder when 18 is divided by 4.

SELECT 18 MOD 4

Example

Calculate the remainder from the division of 18 by 4.

SELECT 18 % 4;