Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Faggregation%2Fsum.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Faggregation%2Fsum.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `sum`

## Description

Returns the total of all numerical values passed into the function.

* Can be used in aggregation to compute totals across grouped rows.
* When used with multiple arguments, returns the sum of all provided values.

## Syntax

```
sum(value: number, ...values: number): number
```

## Arguments

| Name        | Type     | Required | Description                                    |
| ----------- | -------- | -------- | ---------------------------------------------- |
| `value`     | `number` | **true** | The first numerical value to add               |
| `...values` | `number` | **true** | One or more additional numerical values to add |

## Example

**Use case: Calculate total money spent per user**

Suppose you want to compute the total amount of money spent by each user.

### Example data

```
{ "user": "Chris", "product": "Sunglasses", "price": 10 },

{ "user": "Chris", "product": "Car", "price": 1000 },

{ "user": "Dave", "product": "Desk", "price": 250 }
```

### Example query

```
top 10 user by sum(price)
```

### Example output

| user  | sum\_price |
| ----- | ---------- |
| Chris | 1010       |
| Dave  | 250        |
