# Aggregation

Components to aggregate or disaggregate properties in your data in different ways.

## Count

**Description**

Returns a single-row table containing the total number of rows in the input table. The output has one column named 'count' with the row count value.

**Inputs**

* `Source table [Table]`

**Outputs**

* `Result table [Table]`

**External links**

[BigQuery reference](https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions#count)

[Snowflake reference](https://docs.snowflake.com/en/sql-reference/functions/count)

[Redshift reference](https://docs.aws.amazon.com/redshift/latest/dg/r_COUNT.html)

[PostgreSQL reference](https://postgis.net/docs/RT_ST_Count.html)

## Group by

**Description**

Groups rows by one or more columns and computes aggregate statistics (sum, count, avg, min, max, etc.) for other columns. Supports spatial aggregations like union, centroid, convex hull, and make line. Output column names are suffixed with the aggregation method (e.g., 'sales\_sum', 'geom\_centroid').

It is required to convert spatial types to an allowed type by using 'ST\_ASBINARY' before grouping by them.

**Inputs**

* `Source table [Table]`
* `Columns and methods for aggregation [String]`
* `Columns to group by [String]`

**Outputs**

* `Result table [Table]`

[BigQuery reference](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#group_by_clause)

[Snowflake reference](https://docs.snowflake.com/en/sql-reference/constructs/group-by.html)

[Redshift reference](https://docs.aws.amazon.com/redshift/latest/dg/r_GROUP_BY_clause.html)

## Point Stats in Polygons

**Description**

This component adds new columns with statistics computed from the points of a second table that fall within each polygon.

**Inputs**

* `Points table [Table]`
* `Polygons table [Table]`
* `Geo column in points table [Column]`
* `Geo column in polygons table [Column]`
* `Column to compute stats for in points table [Column]`
* `Column with identifier in polygons table [Column]`

**Outputs**

* `Result table [Table]`

## ST Dump

**Description**

This component explodes multi-part geographies into multiple single-part ones.

The output table has the same structure as the input one, but the geo column only contains single part geographies. Rows with multi-part geographies are replaced by several rows with single-part geographies and identical values for the rest of columns.

**Inputs**

* `Source table [Table]`
* `Geo column [Column]`

**Outputs**

* `Result table [Table]`

**External links**

[BigQuery reference](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_dump)

## Summarize

This component creates a new table with aggregated values for the input whole table.

**Inputs**

* `Source table [Table]`
* `Aggregation`: Use the UI of this component to select a list of aggregated properties that will be added to the result table.

**Outputs**

* `Result table [Table]`

## Unnest

**Description**

This component unnests the arrays contained an a column.

**Inputs**

* `Source table [Table]`
* `Column [Column]`

**Outputs**

* `Result table [Table]`

**External links**

[BigQuery reference](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#unnest_operator)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.carto.com/carto-user-manual/workflows/components/aggregation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
