Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions data-explorer/kusto/query/sum-aggregation-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: sum() (aggregation function)
description: Learn how to use the sum() (aggregation function) function to calculate the sum of an expression across the group.
ms.reviewer: alexans
ms.topic: reference
ms.date: 08/11/2024
ms.date: 11/25/2024
---
# sum() (aggregation function)

Expand Down Expand Up @@ -33,33 +33,33 @@ Returns the sum value of *expr* across the group.

## Example

This example returns the total number of deaths by state.
This example returns the total value of crop and property damages by state, and sorted in descending value.

:::moniker range="azure-data-explorer"
> [!div class="nextstepaction"]
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAAwsuyS/KdS1LzSspVuCqUSguzc1NLMqsSlUAiznnl+aV2CaDSA1NHYWQ/JLEHJfUxJIM58Ti1GIFW5B6DbBAsUtmUWpyiaZCUqVCcEliSSrYtPyiEpAAmj4A7Xtp83QAAAA=" target="_blank">Run the query</a>
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAAwsuyS%2FKdS1LzSspVuCqUSguzc1NLMqsSlUAiznnl%2BaV2CaDSA1NHYWQ%2FJLEHJfE3MT01GIFW5BiDQjPuSi%2FoFgbwg4AslOLSio1FZIqFYJLEktSwQbnF5WABJCNAAAX%2BDSIfAAAAA%3D%3D" target="_blank">Run the query</a>
::: moniker-end

```kusto
StormEvents
| summarize EventCount=count(), TotalDeathCases = sum(DeathsDirect) by State
| sort by TotalDeathCases
| summarize EventCount=count(), TotalDamages = sum(DamageCrops+DamageProperty) by State
| sort by TotalDamages
```

**Output**

The results table shown includes only the first 10 rows.

| State | event_count | TotalDeathCases |
| -------------------- | ----------- | --------------- |
| TEXAS | 4701 | 71 |
| FLORIDA | 1042 | 57 |
| CALIFORNIA | 898 | 48 |
| ILLINOIS | 2022 | 29 |
| ALABAMA | 1315 | 29 |
| MISSOURI | 2016 | 20 |
| NEW YORK | 1750 | 19 |
| KANSAS | 3166 | 17 |
| GEORGIA | 1983 | 17 |
| TENNESSEE | 1125 | 17 |
| ... | ... | ... |
| State | Eventcount | TotalDamages |
| ---- | --- |
| CALIFORNIA | 898 | 2801954600 |
| GEORGIA | 1983 | 1190448750 |
| MISSOURI | 2016 | 1096887450 |
| OKLAHOMA | 1716 | 916557300 |
| MISSISSIPPI | 1218 | 802890160 |
| KANSAS | 3166 | 738830000 |
| TEXAS | 4701 | 572086700 |
| OHIO | 1233 | 417989500 |
| FLORIDA | 1042 | 379455260 |
| NORTH DAKOTA | 905 | 342460100 |
| ... | ... | ... |
Loading