Level 0 · Your toolkit · Card 8 of 9 · by Kaushik Saha
Combine tables
Commands union · join
What these commands do
| Command | What it does | Shape |
|---|---|---|
union | Stacks the rows of two or more tables or queries | union TableA, TableB |
join | Puts rows side by side when a key matches | A | join kind=inner B on Key |
kind=inner | Keeps keys found on both sides | join kind=inner |
kind=leftouter | Keeps every left row, with blanks where the right has no match | join kind=leftouter |
kind=leftanti | Keeps left rows with no match on the right: "in A but not in B" | join kind=leftanti |
In a real workspace you join different tables, such as SigninLogs with AuditLogs, and union sign-in tables
such as SigninLogs and AADNonInteractiveUserSignInLogs. This course has one table so far, so the examples join
two questions about it.
See them work
union stacks two results into one, here the sign-ins from each attacking address:
union
(SigninLogs | where IPAddress == "198.51.100.23" | summarize SignIns = count() | extend Attack = "spray"),
(SigninLogs | where IPAddress == "203.0.113.45" | summarize SignIns = count() | extend Attack = "brute force")
| project Attack, SignIns
Result on the sample · 2 rows
| Attack | SignIns |
|---|---|
| spray | 12 |
| brute force | 11 |
Failures and successes per address, side by side. leftouter keeps the address that never succeeded, with a blank:
let Failures = SigninLogs | where ResultType != "0" | summarize Fails = count() by IPAddress;
let Successes = SigninLogs | where ResultType == "0" | summarize OK = count() by IPAddress;
Failures
| join kind=leftouter Successes on IPAddress
| project IPAddress, Fails, OK
| sort by Fails desc
Result on the sample · 4 rows
| IPAddress | Fails | OK |
|---|---|---|
| 198.51.100.23 | 12 | |
| 203.0.113.45 | 8 | 3 |
| 192.0.2.20 | 3 | 39 |
| 192.0.2.10 | 2 | 54 |
Addresses that failed and never once succeeded, with leftanti:
let Succeeded = SigninLogs | where ResultType == "0" | distinct IPAddress;
SigninLogs
| where ResultType != "0"
| distinct IPAddress
| join kind=leftanti Succeeded on IPAddress
Result on the sample · 1 row
| IPAddress |
|---|
| 198.51.100.23 |
That is the spray: it never got in.
Your turn
Which users signed in from both the Netherlands (NL) and the US? Use two let lists and a join kind=inner.
Write it in the box below and check it. Then compare with one answer; others can be right too.
Show one answer
let InNL = SigninLogs | where Location == "NL" | distinct UserPrincipalName;
let InUS = SigninLogs | where Location == "US" | distinct UserPrincipalName;
InNL
| join kind=inner InUS on UserPrincipalName
| project UserPrincipalName
Result on the sample · 1 row
| UserPrincipalName |
|---|
| alex.morgan@contoso.com |
Check your own query
Write your query for the task above and check it against the real schema.
All data on this page is sample data, made up for this course. The IP addresses come from ranges reserved for documentation, and the people and the company are fictional.
Card by Kaushik Saha. Every query checked with Microsoft.Azure.Kusto.Language 12.4.1 against schema bundle 2026.10.29; every result computed on the course's sample with Kusto-Loco 1.4.9, an open-source KQL engine (credits). The story's clock reads 12:00 UTC on 10 June 2026.