SQL Mathematical Functions and Operators
Mathematical functions and operators operate on numbers and return numbers. If the type of the input argument or arguments is not a number type, NuoDB enforces coercion rules as described by Data Type Conversion to convert the arguments to numbers.
Mathematical Operators
Mathematical operators affect one or two values, perform a mathematical operation, and return a value of a numeric data type.
Operator | Usage | Description |
---|---|---|
|
|
Addition of numeric quantities |
|
|
Subtraction of numeric quantity |
|
|
Multiplication of numeric quantities |
|
|
Division of numeric quantity |
|
|
Modulus, or remainder, from dividing |
Comparison Operators
Numeric comparison operators draw a conclusion based on two numeric values (such as whether one is larger than the other) and returns a value of type boolean, set to either true or false.
Operator | Description |
---|---|
|
less than |
|
greater than |
|
less than or equal to |
|
greater than or equal to |
|
equal |
|
no equal |
Mathematical Functions
In the following table dp
indicates a DOUBLE PRECISION
number and numeric
indicates a fixed point number.
Function | Description |
---|---|
ABS ( |
Absolute value function. Returns the absolute value of a number. The absolute value of a number is its distance from 0 on the number line.
|
CEIL ( |
Rounds a number up; returns the smallest integer that is greater than or equal to a given numeric expression. The return type has the same type precision and scale as the input type.
|
DEGREES ( |
Radians to degrees
|
FLOOR( |
Rounds a number down; returns the largest number that is less than or equal to the specified number. The return type has the same type precision and scale as the input type. If the input type is not a numeric type, If the input type is not a number, the type transition matrix is used for converting the input to a number. See Data Type Conversion for details on applied coercions.
|
MOD( |
Returns remainder of the division from two numeric values. See Data Type Conversion for details on how NuoDB computes.
|
PI() |
Returns a constant value for pi.
|
POWER(a, b) |
Returns a double precision number representing
|
RADIANS(dp) |
Degrees to radians
|
RAND() |
Random double precision value in the range 0.0 ≤ x < 1.0.
|
RAND(int) |
A call to |
ROUND( |
Round to nearest integer. The return type preserves the type, precision and scale of the input argument.
|
ROUND( |
Round
|
SQRT( |
Square root of the input value as a double precision number.
|
Trigonometric Functions
Trigonometric functions are defined on a double precision input value and return a double precision value. NuoDB supports the following trigonometric functions:
Function | Description |
---|---|
ACOS( |
inverse cosine |
ASIN( |
inverse sine |
ATAN( |
inverse tangent |
ATAN2( |
inverse tangent of |
COS( |
cosine |
COT( |
cotangent |
SIN( |
sine |
TAN( |
tangent |
Bitwise Operators
NuoDB supports the following bitwise operators:
Operator | Description |
---|---|
|
Bitwise |
|
Bitwise |
|
Bitwise |
|
Bitwise |
Parameters to these operators must be of a type that can be converted to a BIGINT
.
The result of any of the above operations is a 64-bit integer (a SQL BIGINT
).