Loading

ES|QL SUM function

Embedded
number

The sum of a numeric expression.

number result
aggregate_metric_double double
dense_vector dense_vector
double double
exponential_histogram double
integer long
long long
tdigest double
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

FROM employees
| STATS total_salary_changes = SUM(MV_MAX(salary_change))
		
total_salary_changes:double
446.75

SUM can also operate on exponential_histogram fields, computing the sum of the values which were used to construct the histograms.

TS exp_histo_sample
| WHERE instance == "instance-0"
| STATS total = ROUND(SUM(responseTime), 2)
		
total:double
1472.74