» Documentation » SQL Reference

Mathematical Functions

ABS

ABS(X) 

Returns the absolute value of number, ie. if X is less than 0, returns -X otherwise, it returns X.

CEIL

CEIL(X) 

Returns the smallest integer value not less than X.

SELECT CEIL(1.23);
-> 2
SELECT CEIL(-1.23);
-> -1 

EXP

EXP(number) 

Returns the exponent of number.

FLOOR

FLOOR(X) 

Returns the largest integer value not greater than X.

SELECT FLOOR(1.99);
->1
SELECT FLOOR(-1.23);
->-2 

LOG

LOG(X) 

Returns the natural logarithm of number, ie. log e(X) or ln(X).

LOG10

LOG10(X) 

Returns the base-10 logarithm of X, ie. log 10(X).

MOD

MOD(N, M) 

Modulo operation. Returns the remainder of N divided by M.

SELECT mod(11,10)
->11 

POW

POW(base,exponent) 

Returns the base raised to the power of exponent, ie. base\^ exponent.

RAND

RAND([seed]) 

Returns a random FLOAT between 0 and 1. The optional seed parameter may be given to yield a reproducible number.

ROUND

ROUND(X,D) 

Rounds the argument X to d decimal places. D can be negative to cause D digits left of the decimal point of the value X to become zero.

SELECT ROUND(1.298, 1);
->1.3
SELECT ROUND(1.298, 0);
->1
SELECT ROUND(23.298, -1);
->20 

SQRT

SQRT(X) 

Returns the square-root of X.