﻿---
title: ES|QL SUM function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/3016/reference/query-languages/esql/functions-operators/aggregation-functions/sum
products:
  - Elasticsearch
---

# ES|QL SUM function
## Syntax

![Embedded](https://www.elastic.co/elastic/docs-builder/docs/3016/reference/query-languages/esql/images/functions/sum.svg)


## Parameters

<definitions>
  <definition term="number">
  </definition>
</definitions>


## Description

The sum of a numeric expression.

## Supported types


| number                                                                       | result       |
|------------------------------------------------------------------------------|--------------|
| aggregate_metric_double                                                      | double       |
| dense_vector                                                                 | dense_vector |
| double                                                                       | double       |
| exponential_histogram <applies-to>Elastic Stack: Preview in 9.3</applies-to> | double       |
| integer                                                                      | long         |
| long                                                                         | long         |
| tdigest <applies-to>Elastic Stack: Preview in 9.3</applies-to>               | double       |


## Examples

```esql
FROM employees
| STATS SUM(languages)
```


| SUM(languages):long |
|---------------------|
| 281                 |

The expression can use inline functions. For example, to calculate the sum of each employee’s maximum salary changes, apply the `MV_MAX` function to each row and then sum the results
```esql
FROM employees
| STATS total_salary_changes = SUM(MV_MAX(salary_change))
```


| total_salary_changes:double |
|-----------------------------|
| 446.75                      |