SIGN (NoSQL query)

APPLIES TO: NoSQL

Returns the positive (+1), zero (0), or negative (-1) sign of the specified numeric expression.

Syntax

SIGN(<numeric_expr>)  

Arguments

Description
numeric_expr A numeric expression.

Return types

Returns a numeric expression.

Examples

The following example returns the sign of various numbers from -2 to 2.

SELECT VALUE {
    signNegativeTwo: SIGN(-2),
    signNegativeOne: SIGN(-1),
    signZero: SIGN(0),
    signOne: SIGN(1),
    signTwo: SIGN(2)
}
[
  {
    "signNegativeTwo": -1,
    "signNegativeOne": -1,
    "signZero": 0,
    "signOne": 1,
    "signTwo": 1
  }
]

Remarks

  • This function doesn't use the index.