ARRAY_HISTOGRAM
All functions > ARRAY > ARRAY_HISTOGRAM
Returns a frequency histogram of values in an array as an array of value-count pairs.
Signatures
Returns: Array of value-count pairs sorted by value
ARRAY_HISTOGRAM(array: ARRAY<T>) → ARRAY<ROW(value: T, count: BIGINT)> sql
| Parameter | Type | Required | Description |
|---|---|---|---|
array | ARRAY<T> | Yes | The array to create histogram from |
Notes
- Counts frequency of each distinct value in the array
- Returns array of ROW structures with value and count fields
- Results are sorted by value in ascending order
- NULL values are counted separately
- Empty arrays return empty result
- Useful for analyzing value distributions
On this page