Apr 25 2019 04:59 AM - edited Apr 25 2019 05:00 AM
Hi,
Hope this is an OK place for a Kusto Query language question...
Given some data, where there might be multiple versions of the same data, for instance:
+----+---------+-------+-------+ | ID | Version | Attr1 | Attr2 | +----+---------+-------+-------+ | 1 | 1 | 123 | 10.0 | | 2 | 1 | 123 | 5.0 | | 2 | 2 | 222 | 4.0 | | 3 | 1 | 123 | 5.0 | | 3 | 2 | 222 | 4.0 | | 3 | 3 | 333 | 5.0 | +----+---------+-------+-------+
And, what I want to return are only the latest versions of all the rows, eg:
+----+---------+-------+-------+ | ID | Version | Attr1 | Attr2 | +----+---------+-------+-------+ | 1 | 1 | 123 | 10.0 | | 2 | 2 | 222 | 4.0 | | 3 | 3 | 333 | 5.0 | +----+---------+-------+-------+
Right, now, to achieve that I'm doing:
TableName | top-nested of ID by max(1) , top-nested 1 of Version by max(Version), top-nested of Attr1 by max(1), top-nested of Attr2 by max(1)
It works, but it's not very pretty, and in the real-world there are a lot more columns, so it gets big quick.
Is there a better way to achieve what I'm trying to do?
Apr 25 2019 05:04 AM
SolutionApr 25 2019 05:09 AM
@Yoni - thank you! Works perfectly. For everyone else, this achieves the same results as my original one, but much cleaner and faster:
TableName | summarize arg_max(Version,*) by ID
Apr 25 2019 05:04 AM
Solution