3. Elements of SQL Statements : SQL Functions : Numeric Functions
 
Share this page                  
Numeric Functions
For trigonometric functions (COS, SIN, TAN), specify argument in radians. To convert degrees to radians, use the formula: radians = degrees / 360 * 2 * pi(). The functions ACOS, ASIN, ATAN, AND ATAN2 return a value in radians.
ABS
ABS(n)
Operand type: All numeric types and MONEY
Result type: Same as n
Absolute value of n
ACOS
ACOS(n)
Operand type: All numeric types
Result type: FLOAT
Arccosine of cosine value n
ASIN
ASIN(n)
Operand type: All numeric types
Result type: FLOAT
Arcsine value of sine value n
ATAN
ATAN(n)
Operand type: All numeric types
Result type: FLOAT
Arctangent of n; returns a value from (-pi/2) to pi/2.
ATAN2
ATAN2 (x, y)
Operand type: All numeric types
Result type: FLOAT
Arctangent of angle defined by coordinate pair (x, y)
CEIL
CEIL(n)
CEILING(n)
Operand type: All numeric types and MONEY
Result type: Numeric type, based on operand.
Returns the smallest value greater than or equal to the specified numeric expression.
Returns a decimal if input is decimal, and a float if input is float. Coerces other types to decimal or float, according to normal coercion preferences for the input type, and then returns result based on the coerced input.
COS
COS(n)
Operand type: All numeric types
Result type: FLOAT
Cosine of n; returns a value from -1 to 1.
EXP
EXP(n)
Operand type: All numeric types and MONEY
Result type: FLOAT
Exponential of n
FLOOR
FLOOR(n)
Operand type: All numeric types and MONEY
Result type: Numeric type, based on operand.
Returns the largest value less than, or equal to, the specified numeric expression.
Returns a decimal if input is decimal, and a float if input is float or money. Coerces other types to decimal or float, according to normal coercion preferences for the input type, and then returns result based on the coerced input.
LOG
LOG(n)
LN(n)
Operand type: All numeric types and MONEY
Result type: FLOAT
Natural logarithm of n
MOD
MOD(n,b)
Operand type: INTEGER, SMALLINT, INTEGER1, DECIMAL
Result type: Same as b
n modulo b. The result is the same data type as b. Decimal values are truncated.
PI
PI()
Operand type: None
Result type: FLOAT
Value of pi (ratio of the circumference of a circle to its diameter)
POWER
POWER(x,y)
Operand type: All numeric types
Result type: FLOAT
x to the power of y (identical to x ** y)
ROUND
ROUND(n,i)
Operand type: All numeric types
Result type: Type of n.
Rounds value n at the i'th place right or left of the decimal, depending on whether i is greater or less than 0.
Warning! When used with a floating point argument, rounding errors may occur.
SIGN
SIGN(n)
Operand type: All numeric types and MONEY
Result type: INTEGER
Returns -1 if n < 0, 0 if n = 0, +1 if n > 0
SIN
SIN(n)
Operand type: All numeric types
Result type: FLOAT
Sine of n; returns a value from -1 to 1.
SQRT
SQRT(n)
Operand type: All numeric types and MONEY
Result type: FLOAT
Square root of n
TAN
TAN(n)
Operand type: All numeric types
Result type: FLOAT
Tangent value of angle n
TRUNC
TRUNC(x ,y)
TRUNCATE(x ,y)
Operand type: All numeric types
Result type: DECIMAL
Truncates x at the decimal point, or at y places to the right or left of the decimal, depending on whether y is greater or less than 0.