# Time-series queries

Store timestamped records and summarize them with ordinary SQL.

Source: https://particledb.ai/sql/timeseries/

Store timestamped records and summarize them with ordinary SQL.

## Example

```sql
CREATE TABLE docs_readings (id BIGINT PRIMARY KEY, measured_at TIMESTAMP, value BIGINT);
INSERT INTO docs_readings VALUES
  (1, '2026-01-01 12:10:00', 10),
  (2, '2026-01-01 12:20:00', 30);
```

```sql
SELECT DATE_TRUNC('hour', measured_at) AS hour, AVG(value) AS mean
FROM docs_readings GROUP BY DATE_TRUNC('hour', measured_at)
ORDER BY hour;
```

## Behavior

Both readings fall in the same hour and have a mean of 20. Define your timezone and missing-data policy explicitly. A missing interval is different from a zero-valued measurement. Plan retention as an application or operational policy rather than assuming rows expire automatically.

## Related

[SQL reference](/sql/overview/) · [Application guide](/guides/relational-data/) · [Troubleshooting](/guides/troubleshooting/)
