> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bondata.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Aggregation

> Compute summary statistics like SUM, AVG, COUNT across grouped data

Computes aggregation functions (SUM, AVG, COUNT, MIN, MAX, etc.) over grouped data. Typically used after a [Group By](/guide/nodes/transform/group-by-node) node to calculate summaries per group.

## Configuration

| Setting                 | Description                                                 |
| ----------------------- | ----------------------------------------------------------- |
| **Aggregations**        | Formula-based aggregation mappings (optional)               |
| **SQL Aggregations**    | SQL-based aggregation mappings (optional)                   |
| **Virtual Object Name** | Namespace prefix for output fields (default: `aggregation`) |

### Formula Aggregations

| Setting        | Description                                                                      |
| -------------- | -------------------------------------------------------------------------------- |
| **Field Name** | Name for the aggregated field                                                    |
| **Formula**    | Aggregation expression using `SUM()`, `AVG()`, `COUNT()`, `MIN()`, `MAX()`, etc. |

### SQL Aggregations

| Setting            | Description                       |
| ------------------ | --------------------------------- |
| **Field Name**     | Name for the aggregated field     |
| **SQL Expression** | DuckDB SQL aggregation expression |

## How It Works

<Steps>
  <Step title="Group your data first">
    Place a [Group By](/guide/nodes/transform/group-by-node) node before this one to define how records should be grouped.
  </Step>

  <Step title="Define aggregations">
    Add one or more aggregation fields. Each computes a summary value across the records in each group.
  </Step>

  <Step title="Use results downstream">
    The aggregated fields become available as **Mentions** in downstream nodes.
  </Step>
</Steps>

## Output

New aggregated columns are added, computed per group. Output fields are named `{virtual_object_name}.{field_name}`.

## Example

Calculate total revenue and deal count per industry:

1. **Group By** → Industry
2. **Aggregation:**
   * `total_revenue` = `SUM({{Salesforce.Account.Revenue}})`
   * `deal_count` = `COUNT({{Salesforce.Account.Id}})`
   * `avg_deal_size` = `AVG({{Salesforce.Account.Revenue}})`

## Best Practices

* Always place a **Group By** node before this node - aggregation without grouping produces a single result for the entire dataset
* Nested functions and mathematical operations are supported (e.g., `SUM(field) / COUNT(field)`)
* Use SQL aggregations for complex expressions

## Related Nodes

* **[Group By](/guide/nodes/transform/group-by-node)** - required before Aggregation to define groups
* **[Transform](/guide/nodes/transform/transform-node)** - compute per-row fields (not aggregations)
* **[Split Group](/guide/nodes/transform/split-group-node)** - remove grouping after aggregation
