# Group a Table

### Overview

This procedure groups a table by the values in a specific column, and optionally aggregates other columns. This helps you organize and summarize data into meaningful categories. It's useful when you want to analyze totals, averages, or counts within each group, such as total sales by region or number of employees per department.

### Syntax

Below is a line-by-line overview of the automation syntax. Expand each line to learn more.

<details>

<summary><code>group the table by {thing}</code></summary>

#### What does it do?

Groups the table by the specified column and applies optional aggregation on other columns.

#### Where does it go?

This phrase should be written on a **new line**.

#### Is it required?

✅ Yes — This phrase is **required**.

#### Does it require data?

✅ Yes — A reference to **the table** is required. Replace **thing** with the column to group by.

#### Example

```
group the table by Project
```

</details>

<details>

<summary><code>the other columns are</code></summary>

#### What does it do?

Provides an optional list of columns with aggregation functions to apply.

#### Where does it go?

Indented under `group the table by <thing> with`.

#### Is it required?

❌ No — This phrase is **optional**.

#### Does it require data?

✅ Yes — Supported aggregation functions are `Sum`, `Average`, and `Count`. To specify aggregation, list the columns in this format: "{Column-Name}'s {Aggregation-Function}". For example: `"Salary's Sum"`, `"Name's Count"`, or `"Score's Average"`. If not specified, a count of rows for each group will be returned.

#### Example

```
the other columns are "Salary's Sum", "Age's Mean"
```

</details>

### Examples

#### 1. Example 1

```
create a sample table
group the table's rows by City
```

#### 2. Example 2

```
group the table by City where
    the other columns are "Salary's Sum", "Age's Mean"
```
