﻿---
title: ES|QL SUM_OVER_TIME function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/2824/reference/query-languages/esql/functions-operators/time-series-aggregation-functions/sum_over_time
products:
  - Elasticsearch
---

# ES|QL SUM_OVER_TIME function
<applies-to>
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Preview since 9.2
</applies-to>


## Syntax

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


## Parameters

<definitions>
  <definition term="field">
    the metric field to calculate the value for
  </definition>
  <definition term="window">
    the time window over which to compute the sum over time
  </definition>
</definitions>


## Description

Calculates the sum over time value of a field.

## Supported types


| field                                                                           | window                                                                  | result |
|---------------------------------------------------------------------------------|-------------------------------------------------------------------------|--------|
| aggregate_metric_double                                                         | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |
| double                                                                          | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |
| exponential_histogram <applies-to>Elastic Stack: Preview since 9.3</applies-to> | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |
| integer                                                                         | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | long   |
| long                                                                            | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | long   |
| tdigest <applies-to>Elastic Stack: Preview since 9.3</applies-to>               | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |


## Example

```esql
TS k8s
| STATS sum_cost=SUM(SUM_OVER_TIME(network.cost)) BY cluster, time_bucket = TBUCKET(1minute)
```


| sum_cost:double | cluster:keyword | time_bucket:datetime     |
|-----------------|-----------------|--------------------------|
| 67.625          | qa              | 2024-05-10T00:17:00.000Z |
| 65.75           | staging         | 2024-05-10T00:09:00.000Z |