Rediger

Del via


ROUND (NoSQL query)

APPLIES TO: NoSQL

Returns a numeric value, rounded to the closest integer value.

Syntax

ROUND(<numeric_expr>)  

Arguments

Description
numeric_expr A numeric expression.

Return types

Returns a numeric expression.

Examples

The following example rounds positive and negative numbers to the nearest integer.

SELECT VALUE {
    roundTwoPointFour: ROUND(2.4),
    roundTwoPointSix: ROUND(2.6),
    roundTwoPointFive: ROUND(2.5),
    roundNegativeTwoPointFour: ROUND(-2.4),
    roundNegativeTwoPointSix: ROUND(-2.6)
}
[
  {
    "roundTwoPointFour": 2,
    "roundTwoPointSix": 3,
    "roundTwoPointFive": 3,
    "roundNegativeTwoPointFour": -2,
    "roundNegativeTwoPointSix": -3
  }
]

Remarks

  • This function benefits from a range index.
  • The rounding operation performed follows midpoint rounding away from zero. If the input is a numeric expression, which falls exactly between two integers then the result is the closest integer value away from 0. Examples are provided here: | | Rounded | | --- | --- | | -6.5000 | -7 | | -0.5 | -1 | | 0.5 | 1 | | 6.5000 | 7 |