Operator | Description and Comments | Example | ||
---|---|---|---|---|
numeric_type + numeric_type | Addition | 10 + 5 => 15 | ||
+ numeric_type | Unary plus (no operation) | +10.5 => 10.5 | ||
numeric_type - numeric_type | Subtraction | 10 - 5 => 5 | ||
- numeric_type | Negation | -10 => (-10) | ||
numeric_type * numeric_type | Multiplication | 10 * 5 => 50 | ||
numeric_type / numeric_type | Division See also DIV(). See notes. | 5 / 2 => 26 / 2 => 3 | ||
numeric_type % numeric_type | Modulo See also MOD(). See notes. | 5 % 3 => 2 | ||
numeric_type ^ numeric_type | Exponentiation 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_type | Absolute See also ABS() | @ -66.7 => 66.7 |
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
SELECT 2 ^ (3 ^ 3);
Result: 134,217,728
SELECT 2 ^ 3 ^ 3;
Result: 512
%
): Arguments can be either integral_type
(INT
, BIGINT
, SMALLINT
) or DECIMAL
. It cannot be floating-point numbers (FLOAT
or REAL
).