Mathematical functions (Azure Cosmos DB)

APPLIES TO: NoSQL

The mathematical functions each perform a calculation, based on input values that are provided as arguments, and return a numeric value.

You can run queries like the following example:

    SELECT VALUE ABS(-4)

The result is:

    [4]

Functions

The following supported built-in mathematical functions perform a calculation, usually based on input arguments, and return a numeric expression. The index usage column assumes, where applicable, that you're comparing the mathematical system function to another value with an equality filter.

System function Index usage Index usage in queries with scalar aggregate functions Remarks
ABS Index seek Index seek
ACOS Full scan Full scan
ASIN Full scan Full scan
ATAN Full scan Full scan
ATN2 Full scan Full scan
CEILING Index seek Index seek
COS Full scan Full scan
COT Full scan Full scan
DEGREES Index seek Index seek
EXP Full scan Full scan
FLOOR Index seek Index seek
LOG Full scan Full scan
LOG10 Full scan Full scan
PI N/A N/A PI () returns a constant value. Because the result is deterministic, comparisons with PI() can use the index.
POWER Full scan Full scan
RADIANS Index seek Index seek
RAND N/A N/A Rand() returns a random number. Because the result is non-deterministic, comparisons that involve Rand() cannot use the index.
ROUND Index seek Index seek
SIGN Index seek Index seek
SIN Full scan Full scan
SQRT Full scan Full scan
SQUARE Full scan Full scan
TAN Full scan Full scan
TRUNC Index seek Index seek

Next steps