# Analyze live data

Use SQL aggregates and grouping to inspect application records without maintaining a second copy.

Source: https://particledb.ai/guides/analytics/

Run this example in a connected SQL client. It uses a small set of application events.

## Create sample data

```sql
CREATE TABLE task_events (
  id BIGINT PRIMARY KEY,
  team TEXT,
  duration_ms BIGINT
);
INSERT INTO task_events VALUES
  (1, 'support', 100),
  (2, 'support', 300),
  (3, 'platform', 200);
```

## Summarize by team

```sql
SELECT team, COUNT(*) AS runs, AVG(duration_ms) AS mean_ms
FROM task_events
GROUP BY team
ORDER BY team;
```

The platform team has one run; support has two. Both have a mean duration of 200 milliseconds.

## Filter before grouping

```sql
SELECT team, COUNT(*) AS slow_runs
FROM task_events
WHERE duration_ms > 150
GROUP BY team
ORDER BY team;
```

Each team has one matching run. Real workloads need representative data and query measurements. Small examples demonstrate behavior, not benchmark performance.

## Next steps

[Aggregations](/sql/aggregations/) · [Window functions](/sql/window-functions/) · [Query performance](/guides/query-performance/)
