> For the complete documentation index, see [llms.txt](https://upsolver.gitbook.io/content/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://upsolver.gitbook.io/content/reference-1/functions-and-operators/functions/aggregate/max_time_series.md).

# MAX\_TIME\_SERIES

Returns the maximum value per time interval. This aggregation is useful for collecting time-series data for graphs.&#x20;

The size of the time intervals is configurable and dynamic; the time interval used changes depending on how many points you wish to hold per aggregation key.

The time interval and/or the number of points per interval can be changed to suit your needs.

## Syntax

```sql
MAX_TIME_SERIES([MAX_POINTS, INTERVALS,] TIME, VALUE)
```

## Arguments

#### `MAX_POINTS`

Type: `integer`

Default: 300

(Optional) The maximum amount of points to hold before reducing the resolution to the next interval size.

#### `INTERVALS`

Type: array

Default: `[60000, 300000, 600000, 1800000, 3600000, 10800000, 21600000, 43200000, 86400000]`

(Optional) Array of integers representing the time interval buckets in epoch ms for which to return data.&#x20;

If the aggregation has more than `MAX_POINTS` values in the given window, it will use the next interval from this array to reduce the amount of points to comply with `MAX_POINTS`.

#### `TIME`

Type: `numeric`

The field with the time in epoch ms that `VALUE` is associated with.

#### `VALUE`

Type: any

The field to get the maximum value of per `TIME` bucket.

## Returns

Type: `array`

Returns an array of key-value pairs where the key is the time (in epoch ms) and the value is the maximum `VALUE` from within that time frame.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://upsolver.gitbook.io/content/reference-1/functions-and-operators/functions/aggregate/max_time_series.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
