Buddy26
Buddy26

Reputation: 39

Kusto Query: Join multiple tables

TablesA, TableB, TableC

After joining the tables: TableA, TableB, TableC using Kusto Query how to show the value of column: IsPriLoc in the column: PriLoc and IsSecLoc in SecLoc. Below is the expected result

ExpectedResult

Upvotes: 1

Views: 8888

Answers (1)

rony l
rony l

Reputation: 6022

I made a couple of assumptions (regarding data types for example) but this query delivers the required results:

Link to execute on Kusto help cluster

let A = datatable (GUID_PK: string, Name: string, Desc: string) [
    "1", "Test1", "Desc1",
    "2", "Test2", "Desc2",
    "3", "Test3", "Desc3",
    "4", "Test4", "Desc4",
    "5", "Test5", "Desc5",
    "6", "Test6", "Desc6"
    ];
let B = datatable (GUID_FK: string, PriLoc: string, SecLoc: string) [
    "1", "PriLoc1", "SecLoc1",
    "3", "PriLoc3", "SecLoc3",
    "5", "PriLoc5", "SecLoc5",
    ];
let C = datatable (GUID_FK: string, IsPriLoc: string, IsSecLoc: string) [
    "2", "TRUE", "FALSE",
    "4", "FALSE", "TRUE",
    "6", "TRUE", "FALSE",
    ];
let BC = B 
    | union (
        C 
        | project GUID_FK, PriLoc=IsPriLoc, SecLoc=IsSecLoc);
A 
| join BC on $left.GUID_PK == $right.GUID_FK

Upvotes: 2

Related Questions