Oracle REMAINDER function

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

Syntax:

select REMAINDER(m,n) from dual;

It is the mathematical expression m / n (m divides n).

Examples :-

1) select REMAINDER(5,3) from dual;

REMAINDER(5,3)
———————-
2

2) select REMAINDER(6,0) from dual;

The above statement will raise an error as divisor is equal to zero. Mathematically division by zero is undefined or infinity.

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

REMAINDER(3,5)
———————-
-2

Some more examples

REMAINDER(5,2) 1
REMAINDER(5,0) ERROR
REMAINDER(5,5) 0
REMAINDER(2,5) -3
REMAINDER(-2,5) -2
REMAINDER(5,-1) 0
REMAINDER(5,0.5) 0
REMAINDER(5,1.2) 0.2

REMAINDER function introduced in Oracle 10g version.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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