SUM (Azure Cosmos DB)SUM (Azure Cosmos DB)

适用于: SQL API

此聚合函数返回表达式中值的总和。This aggregate function returns the sum of the values in the expression.

语法Syntax

SUM(<numeric_expr>)  

参数Arguments

numeric_exprnumeric_expr

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

返回类型Return types

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

示例Examples

以下示例返回 propertyA 的总和:The following example returns the sum of propertyA:

SELECT SUM(c.propertyA)
FROM c

备注Remarks

此系统函数将从范围索引中获益。This system function will benefit from a range index. 如果 SUM 中的任何参数是字符串、布尔值或 null,则整个聚合系统函数将返回 undefinedIf any arguments in SUM are string, boolean, or null, the entire aggregate system function will return undefined. 如果任何参数具有 undefined 值,则不会影响 SUM 计算。If any argument has an undefined value, it will be not impact the SUM calculation.

后续步骤Next steps