Επεξεργασία

Κοινή χρήση μέσω


TRUNC (NoSQL query)

APPLIES TO: NoSQL

Returns a numeric value truncated to the closest integer value.

Syntax

TRUNC(<numeric_expr>)

Arguments

Description
numeric_expr A numeric expression.

Return types

Returns a numeric expression.

Examples

This example illustrates various ways to truncate a number to the closest integer.

SELECT VALUE {
    truncateFloatingPoint: TRUNC(2.37),
    truncateNegative: TRUNC(-2.78),
    truncateInteger: TRUNC(2),
    truncateSmallNumber: TRUNC(0.0000714),
    truncatePi: TRUNC(PI())
}
[
  {
    "truncateFloatingPoint": 2,
    "truncateNegative": -2,
    "truncateInteger": 2,
    "truncateSmallNumber": 0,
    "truncatePi": 3
  }
]

Remarks