---
title: "Aggregate"
description: "Introduces the purpose, key configuration fields, and examples of the aggregate query node."
---

# Aggregate

## Node Type

`aggregate`
Use the above `type` value when creating the node; do not use the documentation filename as the type.

## Node Description
Performs aggregate calculations on a specified data table (or associated data), supporting count, sum, average, minimum, and maximum.

## Business Scenario Examples
Counting the number of orders, summing amounts, or calculating average ratings.

## Configuration Items
| Field | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| aggregator | string | count | Yes | Aggregate function: `count`, `sum`, `avg`, `min`, `max`. |
| associated | boolean | false | Yes | Target type: `false` for collection data, `true` for associated collection data. |
| collection | string | None | Yes (if associated=false) | Target data table. For a single data source, use the collection name; for multiple data sources, use `dataSource:collection`. |
| association | object | None | Yes (if associated=true) | Association configuration object, containing `name` (association field name), `associatedKey` (variable path for associated primary key), and `associatedCollection` (source collection name). Usually generated by UI. |
| params.field | string | None | Yes | Name of the field to aggregate. |
| params.filter | object | None | No | Filtering conditions (Filter DSL). See [Common Conventions - filter](../conventions/index.md#the-filter-field-in-trigger-and-node-configuration). |
| params.distinct | boolean | false | No | Only effective for `count`, whether to perform a distinct count. |
| precision | number | 2 | No | Number of decimal places for the result, range 0-14. |

## Branch Description
Does not support branching.

## Test Support
Not supported. This node cannot use CLI `workflow flow-nodes test` or HTTP `flow_nodes:test`, because the server-side instruction does not implement `test()`.

## Example Configuration
```json
{
  "aggregator": "count",
  "associated": false,
  "collection": "orders",
  "params": {
    "field": "id",
    "filter": {
      "status": { "$eq": "paid" }
    },
    "distinct": true
  },
  "precision": 2
}
```

## Output Variables
This node exposes a single root result value, referenced directly as `{{$jobsMapByNodeKey.<nodeKey>}}`.

- Exposed root: the aggregate result of the current node.
- No child field tree is provided; downstream nodes consume the number/string result directly.
- Example reference: `{{$jobsMapByNodeKey.abc123}}`.
