> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/release-1.0.0/configuration-reference/functions/histogram.md).

# Histogram

This section contains reference documentation for the HISTOGRAM function.

Returns the count of data points that fall within each bin as a vector. The bins are left-inclusive and right-exclusive, i.e. `[a, b)`, except for the last one which is inclusive on both sides `[a, b]`.

## Signatures

1. Equal length bins (better performance):

> HISTOGRAM(colName, lower, upper, numBins)

1. Arbitrary increasing bin edges:

> HISTOGRAM(colName, ARRAY\[binEdge1, binEdge2, binEdge3, ...])

## Usage Examples

These examples are based on the [Batch Quick Start](/release-1.0.0/basics/getting-started/quick-start.md#batch).

1. 10 equal-length bins `[0, 20), [20, 30) ... [180, 200]`

```sql
SELECT HISTOGRAM(numberOfGames, 0, 200, 10) AS histogram
FROM baseballStats 
```

| histogram                                        |
| ------------------------------------------------ |
| 32348,21519,11359,7587,5488,5360,6282,7361,585,0 |

1. 6 bins `(- ∞, 1), [1, 10), [10, 50), [50,100), [100,500), [500, 1000]`

```sql
select HISTOGRAM(AtBatting, Array['-Infinity', 1, 10, 50, 100, 500, 1000]) AS histogram
from baseballStats
```

| histogram                          |
| ---------------------------------- |
| 13520,16506,18375,12403,28591,8494 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pinot.apache.org/release-1.0.0/configuration-reference/functions/histogram.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
