---
title: delta() | Tiger Data Docs
description: Calculate the change in a counter from a counter aggregate
---

Since [1.3.0](https://github.com/timescale/timescaledb-toolkit/releases/tag/1.3.0)

Get the change in a counter over a time period. This is the simple delta, computed by subtracting the last seen value from the first, after accounting for resets.

## Samples

Get the change in each counter over the entire time interval in table `foo`.

```
SELECT
    id,
    delta(summary)
FROM (
    SELECT
        id,
        counter_agg(ts, val) AS summary
    FROM foo
    GROUP BY id
) t
```

## Arguments

The syntax is:

```
delta(
    summary CounterSummary
) RETURNS DOUBLE PRECISION
```

| Name      | Type             | Default | Required | Description                                                                                                                      |
| --------- | ---------------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `summary` | `CounterSummary` | -       | ✔        | A counter aggregated created using [`counter_agg`](/docs/reference/toolkit/counters-and-gauges/counter_agg/counter_agg/index.md) |

## Returns

| Column | Type             | Description                                          |
| ------ | ---------------- | ---------------------------------------------------- |
| delta  | DOUBLE PRECISION | The change in the counter over the bucketed interval |
