List of SQL Numeric Functions
ABS(numeric_exp)
Returns the absolute value of numeric_exp.
Example: SELECT ABS(-123456) returns 123456
ACOS(float_exp)
Returns the arccosine of float_exp as an angle, expressed in radians.
Example: SELECT ACOS(.75) returns 0.722734247813416
ASIN(float_exp)
Returns the arcsine of float_exp as an angle, expressed in radians.
Example: SELECT ASIN(.75) returns 0.848062078981481
ATAN(float_exp)
Returns the arctangent of float_exp as an angle, expressed in radians.
Example: SELECT ATAN(.75) returns 0.643501108793284
ATAN2(float_exp1, float_exp2)
Returns the arctangent of the x and y coordinates, specified by float_exp1 and float_exp2, respectively, as an angle, expressed in radians.
In most specifications (like POSIX or IEEE), the y coordinate is specified first, followed by the x coordinate. However, the ATAN2 ODBC specification specifies x, then y.
Example: SELECT ATAN2(.75, .50) returns 0.588002603547568
CEILING(numeric_exp)
Returns the smallest integer greater than or equal to numeric_exp.
Example: SELECT CEILING(.75) returns 1
COS(float_exp)
Returns the cosine of float_exp, where float_exp is an angle expressed in radians.
Example: SELECT COS(.75) returns 0.731688868873821
COT(float_exp)
Returns the cotangent of float_exp, where float_exp is an angle expressed in radians.
Example: SELECT COT(.75) returns 1.07342614854938
DEGREES(numeric_exp)
Returns the number of degrees converted from numeric_exp radians.
Example: SELECT DEGREES(.785398163397448) returns 45
EXP(float_exp)
Returns the exponential value of float_exp.
Example: SELECT EXP(.75) returns 2.11700001661267
FLOOR(numeric_exp)
Returns the largest integer less than or equal to numeric_exp.
Example: SELECT FLOOR(75.5) returns 75
LOG(float_exp)
Returns the natural logarithm of float_exp.
Example: SELECT LOG(.75) returns -0.287682072451781
LOG10(float_exp)
Returns the base 10 logarithm of float_exp.
Example: SELECT LOG10(.75) returns -0.1249387366083
MOD(integer_exp1, integer_exp2)
Returns the remainder (modulus) of integer_exp1 divided by integer_exp2.
Example: SELECT MOD(75, 2) returns 1
PI()
Returns the constant value of pi as a floating point value.
Example: SELECT PI() returns 3.14159265358979
POWER(numeric_exp, integer_exp)
Returns the value of numeric_exp to the power of integer_exp.
Example: SELECT POWER(75, 2) returns 5625
RADIANS(numeric_exp)
Returns the number of radians converted from numeric_exp degrees.
Example: SELECT RADIANS(75) returns 1.30899693899575
RAND(integer_exp)
Returns a random floating point value between 0 and 1 using integer_exp as the optional seed value.
Example: SELECT RAND(75) returns 0.915692611577849
ROUND(numeric_exp, integer_exp)
Returns numeric_exp rounded to integer_exp places right of the decimal point. If integer_exp is negative, numeric_exp is rounded to |integer_exp| places to the left of the decimal point.
Examples:
SELECT ROUND(75.12345678,3) returns 75.123
SELECT ROUND(75.12345676,7) returns 75.1234568
SIGN(numeric_exp)
Returns an indicator of the sign of numeric_exp. If numeric_exp is less than zero, -1 is returned. If numeric_exp equals zero, 0 is returned. If numeric_exp is greater than zero, 1 is returned.
Example: SELECT SIGN(.75) returns 1
SIN(float_exp)
Returns the sine of float_exp, where float_exp is an angle expressed in radians.
Example: SELECT SIN(.75) returns 0.681638760023334
SQRT(float_exp)
Returns the square root of float_exp.
Example: SELECT SQRT(.75) returns 0.866025403784439
TAN(float_exp)
Returns the tangent of float_exp, where float_exp is an angle expressed in radians.
Example: SELECT TAN(.75) returns 0.931596459944072
TRUNCATE(numeric_exp, integer_exp)
Returns numeric_exp truncated to integer_exp places right of the decimal point. If integer_exp is negative, numeric_exp is truncated to |integer_exp| places to the left of the decimal point.
Example: SELECT TRUNCATE(-75.123456, 3) returns -75.123
XOR(numeric_exp, numeric_exp, ...)
Takes parameters and converts them to 64 bit integers, then returns the unsigned 64 bit XOR of those two values. If either value is NULL then the result is NULL.
Examples:
SELECT xor('1234567890', '9876543210', 9876543210) returns 1234567890
SELECT xor('1234567890', '9876543210') returns 8676316216
SELECT xor('1234567890') returns 0
SELECT xor() returns SYNTAX ERROR
XOR64(numeric_exp, numeric_exp)
XOR64(a,b) which takes exactly two parameters and converts them to 64 bit integers. It then returns the unsigned 64 bit XOR of those two values. If either value is NULL then the result is NULL. If there are more or less than two parameters, then an error is returned.
Examples:
SELECT xor64('1234567890', '9876543210') returns 8676316216
SELECT xor64('1234567890') returns SYNTAX ERROR