Case Function in Kusto Query | Azure Data Explorer | Kusto Query Language Tutorial (KQL)

Topic: Case Function in Kusto Query Language.


In this article we are going to learn about Case Statement in Kusto Query Language, this is pretty much the same way what you have learned in other languages so not a big difference here but we are going to experiment and see how exactly it looks in Kusto Query Language.

 //Case ()  
 //Evaluates a list of predicates and returns the first result expression whose predicate is satisfied.  
 //If neither of the predicates return true, the result of the last expression (the else) is returned.  
   
 //Let's create a table Customer  
 //.drop table Customer  
 .create table Customer (CustomerId: long, FName: string,LName:string, Salary: int)   
  .ingest inline into table Customer <|  
 1,Aamir,Shahzad,2000  
 2,Raza,ALI,4000  
 3,Lisa,Rivers,50000  
 4,steve,Ladson,1000  
 5,Robert,Jr,500  
 6,aamir,ali,  
   
   
 Customer  
 | extend   
 SalaryType=case (Salary<=2000 or isnull(Salary) , 'VeryLow'  
 ,Salary>2000 and Salary<=4000, 'Medium'  
 ,'Good')  
   

Video Demo: Case Function in Kusto Query | Azure Data Explorer | Kusto Query Language Tutorial (KQL)

No comments:

Post a Comment