Learn SQL

Arithmetic - Filtering and Ordering

27.7

Lesson

# Modulo operation

We all understand division.

```
9 / 4 = 2
```

In the above case the remainder will be 1.
How do we get the remainder.
To get remainder use `%`

.

```
9 % 2 = 1
```

In the computer science the “modulo operation” gives us the remainder.
`%`

is used to denote “Modulo operation”.
`%`

gives us remainder.

Let’s see some more examples.

```
9 % 5 = 4
6 % 5 = 1
8 % 5 = 3
5 % 5 = 0
```

## Is the number even or odd

`%`

can be used to find if a number is even or odd.
If the remainder is 1 then it is an odd number.
If the remainder is 0 then it is an even number.

```
11 % 2 = 1
12 % 2 = 0
```