# NQLサマライズバイ

`summarize by` ステートメントは、情報をプロパティや時間間隔でグループ化された集約結果に凝縮します。

## プロパティによるグルーピング <a href="#nqlsummarizeby-groupingbyproperty" id="nqlsummarizeby-groupingbyproperty"></a>

`by` の後にフィールド名を入力して、プロパティによる内訳を作成します。 追加のフィールド名をカンマで区切って入力し、さらなる内訳の次元を作成します。

{% hint style="info" %}
`summarize by` 節は `days_since_last_seen`（整数）、`last_seen`（日付）、`hardware.memory`（バイト）などの数値データタイプのプロパティによるグルーピングをサポートしていません。
{% endhint %}

### 構文 <a href="#nqlsummarizeby-syntax" id="nqlsummarizeby-syntax"></a>

{% code overflow="wrap" lineNumbers="true" %}

```

  | summarize <新しいメトリック名> = <メトリック>.<集約関数> by <フィールド_1>, <フィールド_2> ...
```

{% endcode %}

### 例 <a href="#nqlsummarizeby-example" id="nqlsummarizeby-example"></a>

過去7日間のデバイスごとのConfluenceバックエンドページ読み込み時間の平均を表示します。

{% code overflow="wrap" lineNumbers="true" %}

```
web.page_views 過去7d
| where application.name == "Confluence"
| summarize backendTime = page_load_time.backend.avg() by device.name
| list device.name, backendTime
| sort backendTime desc
```

{% endcode %}

| デバイス名           | backendTime |
| --------------- | ----------- |
| device-10d267d2 | 508.2 ms    |
| device-d1d5abc9 | 498.9 ms    |
| device-5117c4c3 | 432.1 ms    |
| device-16834449 | 431.9 ms    |
| device-b634ce84 | 429.4 ms    |
| device-731db075 | 349.8 ms    |
| device-7fb313ef | 293.9 ms    |
| device-a834a720 | 277.6 ms    |
| …               | …           |

## 期間によるグルーピング <a href="#nqlsummarizeby-groupingbyperiod" id="nqlsummarizeby-groupingbyperiod"></a>

時間期間と組み合わせて使用する場合、`summarize by` ステートメントはメトリック値を時間バケットにグループ化します。

### 構文 <a href="#nqlsummarizeby-syntax.1" id="nqlsummarizeby-syntax.1"></a>

{% code overflow="wrap" lineNumbers="true" %}

```

  | summarize <新しいメトリック名> = <メトリック>.<集約関数> by <時間期間>
```

{% endcode %}

有効な期間値は次のとおりです：

* `15 min` `30 min` `45 min` …\
  値は15の倍数でなければなりません。
* `1 h` `2 h` `3 h` ...\
  値は整数でなければなりません。
* `1 d` `2 d` `3 d` ...\
  値は整数でなければなりません。

### 例 <a href="#nqlsummarizeby-example.1" id="nqlsummarizeby-example.1"></a>

過去7日間のクラッシュの毎日の数を時系列順に表示します。

{% code overflow="wrap" lineNumbers="true" %}

```
execution.crashes 過去7d
  | summarize total_number_of_crashes = count() by 1d
  | sort start_time asc
```

{% endcode %}

| 開始\_時間                        | 終了\_時間                        | バケット\_期間 | クラッシュの数 |
| ----------------------------- | ----------------------------- | -------- | ------- |
| <p>2021-03-05<br>00:00:00</p> | <p>2021-03-06<br>00:00:00</p> | 1 d      | 758     |
| <p>2021-03-06<br>00:00:00</p> | <p>2021-03-07<br>00:00:00</p> | 1 d      | 700     |
| <p>2021-03-07<br>00:00:00</p> | <p>2021-03-08<br>00:00:00</p> | 1 d      | 954     |
| <p>2021-03-08<br>00:00:00</p> | <p>2021-03-09<br>00:00:00</p> | 1 d      | 493     |
| <p>2021-03-09<br>00:00:00</p> | <p>2021-03-10<br>00:00:00</p> | 1 d      | 344     |
| <p>2021-03-10<br>00:00:00</p> | <p>2021-03-11<br>00:00:00</p> | 1 d      | 765     |
| <p>2021-03-11<br>00:00:00</p> | <p>2021-03-12<br>00:00:00</p> | 1 d      | 857     |

## プロパティと期間によるグルーピング <a href="#nqlsummarizeby-groupingbypropertyandperiod" id="nqlsummarizeby-groupingbypropertyandperiod"></a>

プロパティと時間期間を組み合わせて、追加の内訳をもつ時間バケットを生成します。 複数のフィールドを使用できますが、時間期間選択子は1つのみです。 項目の順序は任意ですが、時間期間選択子はフィールドのリスト内の任意の位置に配置できます。

### 構文 <a href="#nqlsummarizeby-syntax.2" id="nqlsummarizeby-syntax.2"></a>

{% code overflow="wrap" lineNumbers="true" %}

```

  | summarize <新しいメトリック名> = <メトリック>.<集約関数> by <フィールド_1>, <フィールド_2>, ... <時間期間>, ...
```

{% endcode %}

### 例 <a href="#nqlsummarizeby-example.2" id="nqlsummarizeby-example.2"></a>

過去30日間のクラッシュ数をオペレーティングシステムプラットフォームで内訳して、クラッシュ数の多い順に並べ替えて表示します。

{% code overflow="wrap" lineNumbers="true" %}

```
execution.crashes 過去30d
  | summarize total_number_of_crashes = count() by 1d, device.operating_system.platform 
  | sort total_number_of_crashes desc
```

{% endcode %}

| デバイスプラットフォーム | 開始\_時間                        | 終了\_時間                        | バケット\_期間 | クラッシュの数 |
| ------------ | ----------------------------- | ----------------------------- | -------- | ------- |
| Windows      | <p>2021-12-07<br>00:00:00</p> | <p>2021-12-08<br>00:00:00</p> | 1 d      | 690     |
| Windows      | <p>2021-12-08<br>00:00:00</p> | <p>2021-12-09<br>00:00:00</p> | 1 d      | 533     |
| macOS        | <p>2021-12-20<br>00:00:00</p> | <p>2021-12-21<br>00:00:00</p> | 1 d      | 511     |
| Windows      | <p>2021-12-17<br>00:00:00</p> | <p>2021-12-18<br>00:00:00</p> | 1 d      | 493     |
| Windows      | <p>2021-12-08<br>00:00:00</p> | <p>2021-12-09<br>00:00:00</p> | 1d       | 356     |
| macOS        | <p>2021-12-20<br>00:00:00</p> | <p>2021-12-21<br>00:00:00</p> | 1d       | 325     |
| …            | …                             | …                             | …        | …       |


---

# 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.nexthink.com/platform/ja/understanding-key-data-platform-concepts/nexthink-query-language-nql/nql-keywords/nql-summarize-by.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.
