Oracle: MOD() Function

As primary computer operators, we have a special operator that performs a specific function.  For Instance, we perform a simple division, So now we have: Dividend, Divisor, Quotient & Remainder.

(Refer to the below diagram to understand these terms)

remainder

Division operator i.e. is forward-slash(/), is used to find the quotient of the division performed between 2 numbers. For Example- 6 / 2 = 3.

MOD() Function in Oracle finds out the remainder of the division performed between 2 numbers. For Example: We divide 7 / 2 and, the remainder will be 1 in such a case.

Now, Let's consider a case where we need to find the detail of those students in the Stu table, who have even Roll no.

HINT: If we divide any even number by 2 it always gives its remainder as 0.

In such situation we can apply MOD() function in such a way that if we divide the roll_no by 2 it should give the remainder as 0. 

Syntax:

MOD(Dividend, Divisor)

Example:-

Select * from Stu WHERE MOD(roll_no, 2) = 0;

Output:

MOD()