How to Use Top Operator in Kusto Query to Get Top N Records | Kusto Query Language Tutorial (KQL)

Topic: How to Use Top Operator in Kusto Query to Get Top N Records

In this article, we are going to learn about the top operator in Kusto top operator in Kusto returns the first N records sorted by the specified column, Kusto Query Language is a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more. The query uses schema entities that are organized in a hierarchy similar to SQL's: databases, tables, and columns.


 //Top operator : Returns the first N records sorted by the specified columns.  
 // .drop table Customer  
 .create table Customer(CustomerId:int, Name:string)   
  .ingest inline into table Customer <|  
 1,Aamir  
 1,Raza  
 2,Lisa  
 3,steve  
 int(null),aamirtest  
 4,Ali  
 5,test  
 Customer  
 | top 4 by CustomerId asc  
 // using top to get some sample data and putting nulls at the end  
 Customer  
 | top 50 by CustomerId asc nulls last  

Video Demo: How to Use Top Operator in Kusto Query to Get Top N Records

No comments:

Post a Comment