A newer version of this documentation is available.

# Arithmetic Operators

Arithmetic operations perform basic mathematical operations such as addition, subtraction, multiplication, divisions, and modulo within an expression or any numerical value retrieved as part of query clauses. Additionally, N1QL provides a negation operation which changes the sign of a value.

These arithmetic operators only operate on numbers. In N1QL, arithmetic operators have their usual meaning. However, in any of these expressions, if any operand is MISSING, the value of the expression is MISSING. If any operand is NULL and no operand is MISSING, the value of the expression is NULL. Also, if any operand is not a number, the operator evaluates to NULL.

 Operator Description + Add values. - Subtract right value from left. * Multiply values. / Divide left value by right. % Modulo. Divide left value by right and return the remainder. -value Negate value.

arithmetic-term:

```expression + expression | expression - expression |
expression * expression | expression / expression |
expression % expression | - expression```

Example

This query selects the document where name is 'dave' and returns the name, age, and age times 12.

```SELECT name, age, age*12
AS age_in_months
FROM tutorial
WHERE name = 'dave'

Returns:
{
"age": 45,
"age_in_months": 540,
"name": "dave"
}```