# mode

Get the most frequent value in a group. When multiple modes are present it gives the minimum of all the modes. This behavior can be overridden to get the maximum or the average mode.

## Signature

> MODE(colName, \[reducerType])

## Usage Examples

These examples are based on the [Batch Quick Start](https://docs.pinot.apache.org/release-0.12.1/basics/getting-started/quick-start#batch).

```sql
select mode(yearID) AS value
from baseballStats 
WHERE AtBatting != 0 AND yearID > 2001
```

| value |
| ----- |
| 2008  |

```sql
select mode(yearID, 'AVG') AS value
from baseballStats 
WHERE AtBatting != 0 AND yearID > 2001
```

| value |
| ----- |
| 2010  |

```sql
select mode(yearID, 'MIN') AS value
from baseballStats 
WHERE AtBatting != 0 AND yearID > 2001
```

| value |
| ----- |
| 2008  |

```sql
select mode(yearID, 'MAX') AS value
from baseballStats 
WHERE AtBatting != 0 AND yearID > 2001
```

| value |
| ----- |
| 2012  |


---

# 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.pinot.apache.org/release-0.12.1/configuration-reference/functions/mode.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.
