Level 0 · Your toolkit · Card 4 of 9 · by Kaushik Saha
Put rows in order
Commands sort by · top
What these commands do
| Command | What it does | Shape |
|---|---|---|
sort by | Puts the rows in order: desc for newest or biggest first, asc for oldest or smallest | T | sort by Col desc |
top | Sorts and keeps the first N rows in one step | T | top 5 by Col desc |
See them work
The five newest sign-ins of the morning:
SigninLogs
| top 5 by TimeGenerated desc
| project TimeGenerated, UserPrincipalName, AppDisplayName
Result on the sample · 5 rows
| TimeGenerated | UserPrincipalName | AppDisplayName |
|---|---|---|
| 2026-06-10 11:47:01 | it.admin@contoso.com | Azure Portal |
| 2026-06-10 11:32:04 | it.admin@contoso.com | My Apps |
| 2026-06-10 11:12:27 | it.admin@contoso.com | Office 365 SharePoint Online |
| 2026-06-10 11:06:28 | it.admin@contoso.com | Office 365 Exchange Online |
| 2026-06-10 11:02:40 | sara.lind@contoso.com | Office 365 Exchange Online |
One user's sign-ins, oldest first, so you can read them like a story:
SigninLogs
| where UserPrincipalName == "priya.nair@contoso.com"
| sort by TimeGenerated asc
| project TimeGenerated, AppDisplayName, ResultType
Result on the sample · 12 rows
| TimeGenerated | AppDisplayName | ResultType |
|---|---|---|
| 2026-06-10 07:40:48 | Office 365 Exchange Online | 50126 |
| 2026-06-10 08:09:25 | My Apps | 0 |
| 2026-06-10 08:29:37 | Office 365 Exchange Online | 0 |
| 2026-06-10 08:31:00 | Office 365 Exchange Online | 50074 |
| 2026-06-10 08:31:40 | Office 365 Exchange Online | 0 |
| 2026-06-10 08:38:59 | Microsoft Teams | 0 |
| 2026-06-10 09:02:23 | My Apps | 0 |
| 2026-06-10 09:20:12 | Office 365 Exchange Online | 0 |
| 2026-06-10 09:37:25 | Microsoft Teams | 0 |
| 2026-06-10 09:52:38 | My Apps | 0 |
| 2026-06-10 10:08:59 | Office 365 Exchange Online | 0 |
| 2026-06-10 10:21:42 | Microsoft Teams | 0 |
Your turn
Show the three most recent sign-ins by it.admin@contoso.com, newest first.
Write it in the box below and check it. Then compare with one answer; others can be right too.
Show one answer
SigninLogs
| where UserPrincipalName == "it.admin@contoso.com"
| top 3 by TimeGenerated desc
| project TimeGenerated, AppDisplayName, IPAddress
Result on the sample · 3 rows
| TimeGenerated | AppDisplayName | IPAddress |
|---|---|---|
| 2026-06-10 11:47:01 | Azure Portal | 192.0.2.10 |
| 2026-06-10 11:32:04 | My Apps | 192.0.2.10 |
| 2026-06-10 11:12:27 | Office 365 SharePoint Online | 192.0.2.10 |
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.