TRUNC (Azure Cosmos DB)TRUNC (Azure Cosmos DB)

适用于: SQL API

返回一个数值,截断到最接近的整数值。Returns a numeric value, truncated to the closest integer value.

语法Syntax

TRUNC(<numeric_expr>)  

参数Arguments

numeric_exprnumeric_expr
是一个数值表达式。Is a numeric expression.

返回类型Return types

返回一个数值表达式。Returns a numeric expression.

示例Examples

以下示例将以下正数和负数截断到最接近的整数值。The following example truncates the following positive and negative numbers to the nearest integer value.

SELECT TRUNC(2.4) AS t1, TRUNC(2.6) AS t2, TRUNC(2.5) AS t3, TRUNC(-2.4) AS t4, TRUNC(-2.6) AS t5  

下面是结果集。Here is the result set.

[{t1: 2, t2: 2, t3: 2, t4: -2, t5: -2}]  

备注Remarks

此系统函数将从范围索引中获益。This system function will benefit from a range index.

后续步骤Next steps