# Sum macro

Learn how to calculate the sum of a collection of numbers.

This macro calculates the sum of a [collection](/reference/cql/data-types/core/collection) of numbers.

The sum is the result of adding all the numbers in the collection. For example, the sum of the numbers 2, 3, 4, 7, and 9 is 25. If the collection is empty, the result is zero.

## Syntax

This macro has the following syntax:

```cql
sum of /*<collection>*/
```

You can also prefix the macro with a definite article for readability:

```cql
the sum of /*<collection>*/
```

## Parameters

These are the supported parameters:

- `collection`: `collection`

  The collection of numbers you want to sum. Elements are automatically converted to numbers if necessary.

## Examples

Here is an example of how to sum a collection of numbers:

```cql
sum of [1, 2, "3"] // 6
```
