Exercise: Sample queries

Completed

In the previous unit, we examined the general structure of a KQL query. Now let's try running a few sample queries.

Access demo query environments

Some of the products that use KQL offer free environments that you can use for practicing queries. Choose one of the following tabs that corresponds to the query environment you want to use.

Azure Data Explorer offers a help cluster with different types of data preloaded. You can access this cluster by using the Azure Data Explorer web UI.

Prerequisites

This environment requires a Microsoft account or a Microsoft Entra user identity.

Run sample query

The following query answers the question, "What were the top 10 property damages caused by floods?"

StormEvents
| where EventType == "Flood"
| sort by DamageProperty desc
| take 10

Here's a step-by-step analysis of how the query processes the data.

  1. The query begins with the StormEvents table as the tabular input.
  2. It filters on records for which the EventType column is exactly equal to Flood.
  3. The resulting list is sorted in descending order based on the value in the DamageProperty column.
  4. Finally, the top 10 records are returned.