The following table shows the mathematical operators that are available for the standard numeric types. Unless noted otherwise, all the operators return the same data type as their argument(s).

The right arrow (⇒ ) is used to indicate the result.

OperatorDescription and CommentsExample
numeric_type + numeric_typeAddition10 + 5
=> 15
+ numeric_typeUnary plus (no operation)+10.5
=> 10.5
numeric_type - numeric_typeSubtraction10 - 5
=> 5
- numeric_typeNegation-10
=> (-10)
numeric_type * numeric_typeMultiplication10 * 5
=> 50
numeric_type / numeric_typeDivision
See also DIV(). See notes.
5 / 2 => 2
6 / 2 => 3
numeric_type % numeric_typeModulo
See also MOD(). See notes.
5 % 3
=> 2
numeric_type ^ numeric_typeExponentiation
See also EXP(). See notes.
2 ^ 3
=> 8
2.0 ^ (3.0 * 3.0)
=> 134217728.0
`/ numeric_type`Square root`/ 9.0`
=> 3.0
@ numeric_typeAbsolute
See also ABS()
@ -66.7
=> 66.7

Notes:

  1. Division operator (/): Dividing integral_types returns the quotient of the integer division. To perform real numbers division, at least one of the operands should be non-integer.

    For example:
    SELECT 5/2;

    Result: 2

    SELECT 5/2::DECIMAL; SELECT 5.0/2;

    Result: 2.5000000000000000

  2. Exponentiation operator (^): By default, multiple uses of ^ are associated left to right.

    For example:

    SELECT 2 ^ (3 ^ 3);

    Result: 134,217,728

    SELECT 2 ^ 3 ^ 3;

    Result: 512

  3. Modulo operator(%): Arguments can be either integral_type (INT, BIGINT, SMALLINT) or DECIMAL. It cannot be floating-point numbers (FLOAT or REAL).