# `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       |
