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

# countResample

> countにResample コンビネータを適用する例

<div id="description">
  ## 説明
</div>

[`Resample`](/ja/reference/functions/aggregate-functions/combinators#-resample)
コンビネータは、[`count`](/ja/reference/functions/aggregate-functions/count)
集約関数に適用でき、指定したキーカラムの値を一定数
のインターバル (`N`) に分けてカウントできます。

<div id="example-usage">
  ## 使用例
</div>

<div id="basic-example">
  ### 基本的な例
</div>

例を見てみましょう。従業員の`name`、`age`、`wage`を格納するテーブルを作成し、
そこにいくつかのデータを挿入します。

```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);
```

年齢が `[30,60)` および
`[60,75)` のインターバルに含まれるすべての人を数えてみましょう。年齢は整数で表現されるため、対象となる年齢は
`[30, 59]` と `[60,74]` のインターバルになります。これを行うには、`Resample` コンビネータを
`count` に適用します

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

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

<div id="see-also">
  ## 関連項目
</div>

* [`count`](/ja/reference/functions/aggregate-functions/count)
* [`Resample コンビネータ`](/ja/reference/functions/aggregate-functions/combinators#-resample)
