VeriKQL by Kaushik Saha

Level 0 · Your toolkit · Card 4 of 9 · by Kaushik Saha

Put rows in order

Commands sort by · top

What these commands do

CommandWhat it doesShape
sort byPuts the rows in order: desc for newest or biggest first, asc for oldest or smallestT | sort by Col desc
topSorts and keeps the first N rows in one stepT | 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
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 5 rows

TimeGeneratedUserPrincipalNameAppDisplayName
2026-06-10 11:47:01it.admin@contoso.comAzure Portal
2026-06-10 11:32:04it.admin@contoso.comMy Apps
2026-06-10 11:12:27it.admin@contoso.comOffice 365 SharePoint Online
2026-06-10 11:06:28it.admin@contoso.comOffice 365 Exchange Online
2026-06-10 11:02:40sara.lind@contoso.comOffice 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
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 12 rows

TimeGeneratedAppDisplayNameResultType
2026-06-10 07:40:48Office 365 Exchange Online50126
2026-06-10 08:09:25My Apps0
2026-06-10 08:29:37Office 365 Exchange Online0
2026-06-10 08:31:00Office 365 Exchange Online50074
2026-06-10 08:31:40Office 365 Exchange Online0
2026-06-10 08:38:59Microsoft Teams0
2026-06-10 09:02:23My Apps0
2026-06-10 09:20:12Office 365 Exchange Online0
2026-06-10 09:37:25Microsoft Teams0
2026-06-10 09:52:38My Apps0
2026-06-10 10:08:59Office 365 Exchange Online0
2026-06-10 10:21:42Microsoft Teams0

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
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 3 rows

TimeGeneratedAppDisplayNameIPAddress
2026-06-10 11:47:01Azure Portal192.0.2.10
2026-06-10 11:32:04My Apps192.0.2.10
2026-06-10 11:12:27Office 365 SharePoint Online192.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.