Oracle MOD function

MOD function returns the remainder of a number divided by another number.


select MOD(m,n) from dual;

It is the mathematical expression m MOD n.

m MOD n returns remainder of m divided by n.

Mathematical Explanation :-

m ≡ b  (mod n)  means (m – b) is divisible by n where b is an integer.

12 ≡  2 (mod 5) means (12 -2) is divisible by 5. ie 10 is divisible by 5.

12 ≡ 0 ( mod 12) means (12 – 0) is divisible by 12.

Examples :-

1) select MOD(10,3) from dual;


2) select MOD(3,0) from dual;


2) select MOD(3,5) from dual;


Some more examples

MOD(5,2) 1
MOD(5,0) 5
MOD(5,5) 0
MOD(2,5) 2
MOD(-2,5) -2
MOD(5,-1) 1
MOD(5,0.5) 0
MOD(5,1.2) 0.2

Oracle has introduced another function REMAINDER in 10g version. Note that MOD and REMAINDER function looks similar but not exactly. Explained in another post.


Author: sqlandplsql

To learn more about the Oracle, SQL, PL SQL, Performance Tuning, Database Modeling, Ubuntu, MySQL etc .Suggestions, comments, feedbacks and referrals are highly appreciated.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s