Applies to: ✅Microsoft Fabric✅Azure Data Explorer✅Azure Monitor✅Microsoft Sentinel
입력된 테이블의 내용을 집계하는 테이블을 생성합니다.
Syntax
T| summarize
[ SummarizeParameters ] [[Column=
] Aggregation [,
...]] [by
[Column=
] GroupExpression [,
...]]
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
Column | string |
결과 열의 이름입니다. 기본적으로 식에서 파생된 이름입니다. | |
Aggregation | string |
✔️ | A call to an aggregation function such as count() or avg() , with column names as arguments. |
GroupExpression | scalar | ✔️ | 입력 데이터를 참조할 수 있는 스칼라 식입니다. 출력에는 모든 그룹 식의 고유 값이 있는 만큼의 레코드가 있습니다. |
SummarizeParameters | string |
Zero or more space-separated parameters in the form of Name= Value that control the behavior. See supported parameters. |
Note
When the input table is empty, the output depends on whether GroupExpression is used:
- If GroupExpression isn't provided, the output is a single (empty) row.
- If GroupExpression is provided, the output has no rows.
Supported parameters
Name | Description |
---|---|
hint.num_partitions |
클러스터 노드에서 쿼리 부하를 공유하는 데 사용되는 파티션 수를 지정합니다. See shuffle query |
hint.shufflekey=<key> |
쿼리는 shufflekey 키를 사용하여 데이터를 분할하는 클러스터 노드의 쿼리 부하를 공유합니다. See shuffle query |
hint.strategy=shuffle |
전략 쿼리는 shuffle 각 노드가 데이터의 한 파티션을 처리하는 클러스터 노드의 쿼리 부하를 공유합니다. See shuffle query |
Returns
입력 행은 식 값 by
이 동일한 그룹으로 정렬됩니다. 그런 다음, 지정된 집계 함수가 각 그룹에 대해 계산되어 각 그룹에 대해 행을 생성합니다. 결과에는 각 계산된 집계에 by
대해 하나 이상의 열과 열이 포함됩니다. (일부 집계 함수는 여러 열을 반환합니다.)
결과에는 값의 고유한 조합(0일 수 있음)이 있는 만큼의 by
행이 있습니다. 그룹 키가 제공되지 않으면 결과에 단일 레코드가 있습니다.
숫자 값 bin()
의 범위에 대해 요약하려면 범위를 줄여 불연속 값으로 줄입니다.
Note
- 집계 및 그룹화 식 모두에 대해 임의의 식을 제공할 수 있지만 단순 열 이름을 사용하거나 숫자 열에 적용
bin()
하는 것이 더 효율적입니다. - datetime 열에 대한 자동 시간별 bin은 더 이상 지원되지 않습니다. 대신 명시적 범주화를 사용합니다. 예들 들어
summarize by bin(timestamp, 1h)
입니다.
집계의 기본값
다음 표에는 집계의 기본값이 요약되어 있습니다.
Operator | Default value |
---|---|
count() , countif() , dcount() , dcountif() , count_distinct() , sum() , sumif() , variance() varianceif() , stdev() stdevif() |
0 |
make_bag() , make_bag_if() , make_list() , make_list_if() , make_set() make_set_if() |
빈 동적 배열([]) |
All others | null |
Note
null 값을 포함하는 엔터티에 이러한 집계를 적용하는 경우 null 값은 무시되며 계산에 포함되지 않습니다. See Examples.
Examples
The examples in this article use publicly available tables in the help cluster, such as the
StormEvents
table in the Samples database.
The examples in this article use publicly available tables, such as the
Weather
table in the Weather analytics sample gallery. 작업 영역의 테이블과 일치하도록 예제 쿼리에서 테이블 이름을 수정해야 할 수 있습니다.
다음 예제에서는 직접적인 부상을 초래한 폭풍의 State
고유한 조합과 EventType
그 조합을 결정합니다. 집계 함수는 없으며 그룹별 키만 있습니다. 출력에는 해당 결과의 열만 표시됩니다.
StormEvents
| where InjuriesDirect > 0
| summarize by State, EventType
Output
다음 표에서는 처음 5개 행만 보여 줍니다. 전체 출력을 보려면 쿼리를 실행합니다.
State | EventType |
---|---|
TEXAS | Thunderstorm Wind |
TEXAS | Flash Flood |
TEXAS | Winter Weather |
TEXAS | High Wind |
TEXAS | Flood |
... | ... |
다음 예제에서는 하와이에서 최소 및 최대 폭우 폭풍을 찾습니다. group-by 절이 없으므로 출력에 행이 하나만 있습니다.
StormEvents
| where State == "HAWAII" and EventType == "Heavy Rain"
| project Duration = EndTime - StartTime
| summarize Min = min(Duration), Max = max(Duration)
Output
Min | Max |
---|---|
01:08:00 | 11:55:00 |
다음 예제에서는 각 상태에 대한 고유한 Storm 이벤트 유형 수를 계산하고 결과를 고유한 Storm 유형의 수로 정렬합니다.
StormEvents
| summarize TypesOfStorms=dcount(EventType) by State
| sort by TypesOfStorms
Output
다음 표에서는 처음 5개 행만 보여 줍니다. 전체 출력을 보려면 쿼리를 실행합니다.
State | TypesOfStorms |
---|---|
TEXAS | 27 |
CALIFORNIA | 26 |
PENNSYLVANIA | 25 |
GEORGIA | 24 |
ILLINOIS | 23 |
... | ... |
다음 예제에서는 폭풍이 1일 이상 지속된 히스토그램 폭풍 이벤트 유형을 계산합니다.
Duration
값이 많으므로 해당 값을 bin()
1일 간격으로 그룹화합니다.
StormEvents
| project EventType, Duration = EndTime - StartTime
| where Duration > 1d
| summarize EventCount=count() by EventType, Length=bin(Duration, 1d)
| sort by Length
Output
EventType | Length | EventCount |
---|---|---|
Drought | 30.00:00:00 | 1646 |
Wildfire | 30.00:00:00 | 11 |
Heat | 30.00:00:00 | 14 |
Flood | 30.00:00:00 | 20 |
Heavy Rain | 29.00:00:00 | 42 |
... | ... | ... |
다음 예제에서는 입력 테이블이 비어 있는 경우 집계의 기본값을 보여 줍니다.
summarize
연산자는 집계의 기본값을 계산하는 데 사용됩니다.
연산자의 summarize
입력에 하나 이상의 빈 그룹별 키가 있는 경우 그 결과도 비어 있습니다.
연산자의 summarize
입력에 빈 그룹별 키가 없는 경우 결과는 자세한 내용은 집계의 summarize
기본값을 참조하세요.
datatable(x:long)[]
| summarize any_x=take_any(x), arg_max_x=arg_max(x, *), arg_min_x=arg_min(x, *), avg(x), buildschema(todynamic(tostring(x))), max(x), min(x), percentile(x, 55), hll(x) ,stdev(x), sum(x), sumif(x, x > 0), tdigest(x), variance(x)
Output
any_x | arg_max_x | arg_min_x | avg_x | schema_x | max_x | min_x | percentile_x_55 | hll_x | stdev_x | sum_x | sumif_x | tdigest_x | variance_x |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
NaN | 0 | 0 | 0 | 0 |
결과는 avg_x(x)
0으로 나누기 때문입니다 NaN
.
datatable(x:long)[]
| summarize count(x), countif(x > 0) , dcount(x), dcountif(x, x > 0)
Output
count_x | countif_ | dcount_x | dcountif_x |
---|---|---|---|
0 | 0 | 0 | 0 |
datatable(x:long)[]
| summarize make_set(x), make_list(x)
Output
set_x | list_x |
---|---|
[] | [] |
평균 집계는 null이 아닌 값만 합산하고 null을 무시하고 계산에서 해당 값만 계산합니다.
range x from 1 to 4 step 1
| extend y = iff(x == 1, real(null), real(5))
| summarize sum(y), avg(y)
Output
sum_y | avg_y |
---|---|
15 | 5 |
표준 개수 함수에는 해당 개수에 null 값이 포함됩니다.
range x from 1 to 2 step 1
| extend y = iff(x == 1, real(null), real(5))
| summarize count(y)
Output
count_y |
---|
2 |
range x from 1 to 2 step 1
| extend y = iff(x == 1, real(null), real(5))
| summarize make_set(y), make_set(y)
Output
set_y | set_y1 |
---|---|
[5.0] | [5.0] |