> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8a08bda2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# countResample

> Example of using the Resample combinator with count

<h2 id="description">
  Description
</h2>

The [`Resample`](/reference/functions/aggregate-functions/combinators#-resample)
combinator can be applied to the [`count`](/reference/functions/aggregate-functions/count)
aggregate function to count values of a specified key column in a fixed number
of intervals (`N`).

<h2 id="example-usage">
  Example usage
</h2>

<h3 id="basic-example">
  Basic example
</h3>

Let's look at an example. We'll create a table which contains the `name`, `age` and
`wage` of employees, and we'll insert some data into it:

```sql theme={null}
CREATE TABLE employee_data 
(
    name String,
    age UInt8,
    wage Float32
) 
ENGINE = MergeTree()
ORDER BY tuple()

INSERT INTO employee_data (name, age, wage) VALUES
    ('John', 16, 10.0),
    ('Alice', 30, 15.0),
    ('Mary', 35, 8.0),
    ('Evelyn', 48, 11.5),
    ('David', 62, 9.9),
    ('Brian', 60, 16.0);
```

Let's count all the people whose age lies in the intervals of `[30,60)`
and `[60,75)`. Since we use integer representation for age, we get ages in the
`[30, 59]` and `[60,74]` intervals. To do so we apply the `Resample` combinator
to `count`

```sql theme={null}
SELECT countResample(30, 75, 30)(name, age) AS amount FROM employee_data
```

```response theme={null}
┌─amount─┐
│ [3,2]  │
└────────┘
```

<h2 id="see-also">
  See also
</h2>

* [`count`](/reference/functions/aggregate-functions/count)
* [`Resample combinator`](/reference/functions/aggregate-functions/combinators#-resample)
