SQL Reference > Mathematical Functions

Mathematical Functions

This page covers mathematical operators and functions available in Rockset.

All functions accept arguments of types int and float. The return type is float, unless otherwise specified.

Operators

Rockset supports the basic arithmetic operators shown below on any combination of int and float values.

OperatorDescription
+ xpositive sign
- xnegative sign
x + yaddition
x - ysubtraction
x * ymultiplication
x / ydivision
x % ymodulo (remainder)

Basic Functions

ABS

ABS(x)

Returns absolute value of x. Return type is the same as input.

CEIL

CEIL(x)

Returns the smallest integral value that is not less than x.

CEILING

CEILING(x)

Alias of CEIL.

GREATEST

GREATEST(a, b, c, ...)

Returns the argument that is greater than or equal to all other arguments.

LEAST

LEAST(a, b, c, ...)

Returns the argument that is less than or equal to all other arguments.

SIGN

SIGN(x)

Returns sign of x as an integer: -1 if x is negative, 0 if x is zero, 1 if x is positive.

FLOOR

FLOOR(x)

Returns the largest integral value that is not greater than x.

Log and Exponential Functions

EXP

EXP(x)

Computes e to the power of x.

POW

POW(x, y)

Computes x to the power of y.

POWER

POWER(x, y)

Alias of POW.

SQRT

SQRT(x)

Computes the square root of x.

LN

LN(x)

Computes the natural logarithm of x.

LOG10

LOG10(x)

Computes the base-10 logarithm of x.

LOG2

LOG2(x)

Computes the base-2 logarithm of x.

Trigonometric Functions

ACOS

ACOS(x)

Computes the arc cosine of x.

ACOSH

ACOSH(x)

Computes the inverse hyperbolic cosine of x.

ASIN

ASIN(x)

Computes the arc sine of x.

ASINH

ASINH(x)

Computes the inverse hyperbolic sine of x.

ATAN

ATAN(x)

Computes the arc tangent of x.

ATAN2

ATAN2(y, x)

Computes the arc tangent of y / x, but with proper sign for quadrant correction. That is, correctly computes the angle θ when converting from the Cartesian coordinates (x, y) to the polar coordinates (r, θ).

ATANH

ATANH(x)

Computes the inverse hyperbolic tangent of x.

COS

COS(x)

Computes the cosine of x.

COSH

COSH(x)

Computes the hyperbolic cosine of x.

HYPOT

HYPOT(x, y)

Computes SQRT(x*x + y*y), that is, the length of the hypothenuse of a right-angled triangle with sides of lengths x and y, or the distance between the point at coordinates (x, y) and origin.

SIN

SIN(x)

Computes the sine of x.

SINH

SINH(x)

Computes the hyperbolic sine of x.

TAN

TAN(x)

Computes the tangent of x.

TANH

TANH(x)

Computes the hyperbolic tangent of x.