---
title: last_val() | Tiger Data Docs
description: Get the last value from a TimeWeightSummary aggregate
---

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

Get the value of the last point in a TimeWeightSummary aggregate.

## Samples

Produce a linear TimeWeightSummary over the column `val` and get the last value:

```
WITH t as (
    SELECT
        time_bucket('1 day'::interval, ts) as dt,
        time_weight('Linear', ts, val) AS tw
    FROM table
    GROUP BY time_bucket('1 day'::interval, ts)
)
SELECT
    dt,
    last_val(tw)
FROM t;
```

## Arguments

The syntax is:

```
last_val(
    tw TimeWeightSummary
) RETURNS DOUBLE PRECISION
```

| Name | Type              | Default | Required | Description                                            |
| ---- | ----------------- | ------- | -------- | ------------------------------------------------------ |
| tws  | TimeWeightSummary | -       | ✔        | The input TimeWeightSummary from a time\_weight() call |

## Returns

| Column    | Type             | Description                                            |
| --------- | ---------------- | ------------------------------------------------------ |
| last\_val | DOUBLE PRECISION | The value of the last point in the `TimeWeightSummary` |
