Skip Headers

Oracle9i SQL Reference
Release 2 (9.2)

Part Number A96540-01
 Home Book List Contents Index Master Index Feedback

Functions, 72 of 177

## MOD

#### Syntax

mod::=

Text description of mod

#### Purpose

`MOD` returns the remainder of `m` divided by `n`. Returns `m` if n is 0.

#### Examples

The following example returns the remainder of 11 divided by 4:

```SELECT MOD(11,4) "Modulus" FROM DUAL;

Modulus
----------
3

```

This function behaves differently from the classical mathematical modulus function when m is negative. The classical modulus can be expressed using the `MOD` function with this formula:

```m - n * FLOOR(m/n)

```

The following table illustrates the difference between the `MOD` function and the classical modulus:

m n MOD(m,n) Classical Modulus

`11`

`4`

`3`

`3`

`11`

`-4`

`3`

`-1`

`-11`

`4`

`-3`

`1`

`-11`

`-4`

`-3`

`-3`

 See Also:

Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.
 Home Book List Contents Index Master Index Feedback