> For the complete documentation index, see [llms.txt](https://docs.everos.dev/ever-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.everos.dev/ever-sdk/guides/queries_and_subscriptions/aggregate_collection.md).

# Aggregate Collection

{% hint style="warning" %} <mark style="color:red;">**Collections is an analytics API (not real-time, though it may look like one).**</mark>

<mark style="color:red;">**Not all filters and sortings are working now. Data is provided only for the past 7 days.**</mark>
{% endhint %}

## When you may need aggregate of collections?

If you want to apply some aggregators like COUNT, MAX, MIN, SUM, AVERAGE on some blockchain data.

## Usage

```javascript
const aggregationFunctionsResults = result = 
        (await client.net.aggregate_collection({
        collection: 'accounts',
        fields: [
            {
                field: "balance",
                fn: "MIN"
            },
            {
                field: "balance",
                fn: "MAX"
            }, {
                field: "balance",
                fn: "AVERAGE"
            }, {
                field: "balance",
                fn: "SUM"
            },
            {
                field: "balance",
                fn: "COUNT"
            }
        ]
    })).values;
console.log("Minimum account balance: " + aggregationFunctionsResults[0]);
console.log("Maximum account balance: " + aggregationFunctionsResults[1]);
console.log("Average balance: " + aggregationFunctionsResults[2]);
console.log("Total balance of all accounts: " + aggregationFunctionsResults[3]);
console.log("Number of accounts: " + aggregationFunctionsResults[4] + '\n');
```

## About collections

There are a few collections with blockchain data:

* *accounts*: blockchain account data;
* *transactions*: transactions related to accounts;
* *messages*: input and output messages related to transactions;
* *blocks*: blockchain blocks.
* *block\_signatures* : validator block signatures

[Reference](/ever-sdk/reference/types-and-methods/mod_net.md#aggregate_collection)

Sample: <https://github.com/everx-labs/sdk-samples/tree/master/core-examples/node-js/query>
