A newer version of this documentation is available.

View Latest

Number Functions

  • reference
    +

    Number functions are functions that are performed on a numeric field.

    ABS(expression)

    Returns absolute value of the number.

    ACOS(expression)

    Returns arccosine in radians.

    ASIN(expression)

    Returns arcsine in radians.

    ATAN(expression)

    Returns arctangent in radians.

    ATAN2(expression1, expression2)

    Returns arctangent of expression2/expression1.

    CEIL(expression)

    Returns smallest integer not less than the number.

    COS(expression)

    Returns cosine.

    DEGREES(expression)

    Returns radians to degrees.

    E()

    Base of natural logarithms.

    EXP(expression)

    Returns eexpression.

    LN(expression)

    Returns log base e.

    LOG(expression)

    Returns log base 10.

    FLOOR(expression)

    Largest integer not greater than the number.

    PI()

    Returns PI.

    POWER(expression1, expression2):

    Returns expression1expression2.

    RADIANS(expression)

    Returns degrees to radians.

    RANDOM([ expression ])

    Returns pseudo-random number with optional seed.

    ROUND(expression [, digits ])

    Rounds the value to the given number of integer digits to the right of the decimal point (left if digits is negative). Digits is 0 if not given.

    SIGN(expression)

    Valid values: -1, 0, or 1 for negative, zero, or positive numbers respectively.

    SIN(expression)

    Returns sine.

    SQRT(expression)

    Returns square root.

    TAN(expression)

    Returns tangent.

    TRUNC(expression [, digits ])

    Truncates the number to the given number of integer digits to the right of the decimal point (left if digits is negative). Digits is 0 if not given.

    Example

    SELECT
        AVG(reviews.rating) / 5 AS normalizedRating,
        ROUND((avg(reviews.rating) / 5), 2) AS roundedRating,
        TRUNC((avg(reviews.rating) / 5), 3) AS truncRating
        FROM reviews AS reviews
        WHERE reviews.customerId = "customer62"

    Returns

    {
       "results": [
         {
           "normalizedRating": 0.42000000000000004,
           "roundedRating": 0.42,
           "truncRating": 0.42
         }
       ]
     }