# Aggregate

### Any value

Returns any value from the input or NULL if there are zero input rows –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#any_value)

```sql
ANY_VALUE(@variable)
```

#### Return type

dynamic (input-dependent)

#### Parameters

| Name        | Type                                                                                                                       | Allowed values                                                                           | Required | Placeholder (in UI) |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable` | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | -                   |

### Average

Returns the average of all non-null values –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#avg)

```sql
AVG(@variable)
```

#### Return type

float

#### Parameters

| Name        | Type                                                                                                                       | Allowed values                                                                                                                                     | Required | Placeholder (in UI) |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable` | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [integer](https://docs.redivis.com/reference/datasets/variables#integer), [float](https://docs.redivis.com/reference/datasets/variables#float) | true     | -                   |

### Count

Returns the count of all non-null values –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#count)

```sql
COUNT([@distinct ]@variable)
```

#### Return type

integer

#### Parameters

| Name        | Type                                                                                                                       | Allowed values                                                                           | Required | Placeholder (in UI) |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable` | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | false    | *(\*)*              |
| `@distinct` | [boolean](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#boolean)   | any [boolean](https://docs.redivis.com/reference/datasets/variables#boolean)             | true     | -                   |

### Logical and

Returns the logical AND of all non-NULL expressions –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#logical_and)

```sql
LOGICAL_AND(@variable)
```

#### Return type

boolean

#### Parameters

| Name        | Type                                                                                                                       | Allowed values                                                               | Required | Placeholder (in UI) |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable` | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [boolean](https://docs.redivis.com/reference/datasets/variables#boolean) | true     | -                   |

### Logical or

Returns the logical OR of all non-NULL expressions –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#logical_or)

```sql
LOGICAL_OR(@variable)
```

#### Return type

boolean

#### Parameters

| Name        | Type                                                                                                                       | Allowed values                                                               | Required | Placeholder (in UI) |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable` | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [boolean](https://docs.redivis.com/reference/datasets/variables#boolean) | true     | -                   |

### Max

Returns the maximum value of all non-null inputs –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#max)

```sql
MAX(@variable)
```

#### Return type

dynamic (input-dependent)

#### Parameters

| Name        | Type                                                                                                                       | Allowed values                                                                           | Required | Placeholder (in UI) |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable` | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | -                   |

### Min

Returns the minimum value of all non-null inputs –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#min)

```sql
MIN(@variable)
```

#### Return type

dynamic (input-dependent)

#### Parameters

| Name        | Type                                                                                                                       | Allowed values                                                                           | Required | Placeholder (in UI) |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable` | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | -                   |

### String aggregate

Returns a string obtained by concatenating all non-null values –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#string_agg)

```sql
STRING_AGG([@distinct ]@variable[, @delimiter][ LIMIT @limit])
```

#### Return type

string

#### Parameters

| Name         | Type                                                                                                                       | Allowed values                                                                           | Required | Placeholder (in UI) |
| ------------ | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable`  | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [string](https://docs.redivis.com/reference/datasets/variables#string)               | true     | -                   |
| `@delimiter` | [literal](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#literal)   | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | false    | *(",")*             |
| `@distinct`  | [boolean](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#boolean)   | any [boolean](https://docs.redivis.com/reference/datasets/variables#boolean)             | true     | -                   |
| `@limit`     | [literal](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#literal)   | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | false    | -                   |

### Sum

Returns the sum of all values, ignoring nulls –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#sum)

```sql
SUM(@variable)
```

#### Return type

dynamic (input-dependent)

#### Parameters

| Name        | Type                                                                                                                       | Allowed values                                                                                                                                     | Required | Placeholder (in UI) |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------- |
| `@variable` | [variable](https://docs.redivis.com/reference/projects/transform-nodes/variable-creation-methods/common-elements#variable) | any [integer](https://docs.redivis.com/reference/datasets/variables#integer), [float](https://docs.redivis.com/reference/datasets/variables#float) | true     | -                   |


---

# 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.redivis.com/reference/workflows/transforms/variable-creation-methods/aggregate.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.
