Numeric functions
Basic arithmetic functions
Section titled “Basic arithmetic functions”The standard arithmetic functions are available:
expr1 + expr2(addition)expr1 - expr2(subtraction)expr1 * expr2(multiplication)expr1 / expr2(division)
Other numeric functions
Section titled “Other numeric functions”ABS(x)- absolute value of
x CEIL(x)|CEILING(x)- nearest integer greater than or equal to
x EXP(x)- ℯ (base of natural logarithms) raised to the power of
x FLOOR(x)- nearest integer less than or equal to
x LN(x)- natural logarithm
LOG(x, y)- logarithm of
x, basey LOG10(x)- logarithm of
x, base 10 MOD(x, y)- modulus of
x, basey POWER(x, y)xraised to the `y`th powerROUND(x)|ROUND(x, s)- rounds
xto the nearest integer, or tosdecimal places if specified. When exactly halfway between two values, rounds away from zero (HALF_UP). Supports negativesto round to the left of the decimal point.ROUND(42.5)→43.0ROUND(42.4382, 2)→42.44ROUND(1234.56, -1)→1230.0
- For numeric types (
INTEGER,DOUBLE):scan be a literal or column value. ReturnsDOUBLE. - For
DECIMALtypes:smust be a literal constant. ReturnsDECIMALwith the specified scale. - To use a non-constant scale with
DECIMAL, cast toDOUBLEfirst:ROUND(val::DOUBLE, scale_column)
- Throws an error if the scale parameter would cause numeric overflow.
SQRT(x)- square root
Trigonometric functions
Section titled “Trigonometric functions”ACOS(x)(inverse cosine)ASIN(x)(inverse sine)ATAN(x)(inverse tangent)COS(x)(cosine)COSH(x)(hyperbolic cosine)SIN(x)(sine)SINH(x)(hyperbolic sine)TAN(x)(tangent)TANH(x)(hyperbolic tangent)