# Aggregate records

Summarize rows with COUNT, SUM, AVG and GROUP BY.

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

Summarize rows with COUNT, SUM, AVG and GROUP BY.

## Example

```sql
CREATE TABLE docs_metrics (id BIGINT PRIMARY KEY, team TEXT, amount BIGINT);
INSERT INTO docs_metrics VALUES (1, 'support', 10), (2, 'support', 30), (3, 'platform', 20);
```

```sql
SELECT team, COUNT(*) AS records, SUM(amount) AS total, AVG(amount) AS mean
FROM docs_metrics GROUP BY team ORDER BY team;
```

## Behavior

Platform has one record totaling 20. Support has two totaling 40. `WHERE` filters input records; `HAVING` filters groups. `COUNT(*)` counts rows, while `COUNT(column)` ignores null values.

## Related

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