[英]How to use s skalar stored in 'let' in a where clause with '!contains' in Kusto Query Language
I have a problem which bothers me even though i think the solution must be super simple.我有一个困扰我的问题,尽管我认为解决方案必须非常简单。 I have to build a query with Kusto Query Language for my Azure Analytics log analyzer metric.
我必须使用 Kusto 查询语言为我的 Azure Analytics 日志分析器指标构建查询。
I want to make this script working for the latest app version and for the second latest app version.我想让这个脚本适用于最新的应用程序版本和第二个最新的应用程序版本。
This is the query code to get the latest app version as a skalar.这是获取最新应用程序版本作为 skalar 的查询代码。
customEvents
| where client_OS contains "Android"
| summarize max(application_Version)
Now my understanding would be, that i could store this in a let and use it later on to get the second latest app version like this:现在我的理解是,我可以将它存储在一个 let 中,稍后使用它来获取第二个最新的应用程序版本,如下所示:
let latestVersion = customEvents
| where client_OS contains "Android"
| summarize max(application_Version);
customEvents
| where client_OS contains "Android" and application_Version !contains latestVersion
|summarize max(application_Version)
But unfortunately the compiler wont let me use a skalar with !contains.但不幸的是,编译器不允许我使用带有 !contains 的 skalar。 I have to use a string.
我必须使用字符串。 Is there any way for me to make string out of this, so i can use it?
有什么办法可以让我用它来制作字符串,以便我可以使用它吗? Or do you have any other good way to retrieve the second highest value from application_Version column?
或者您有其他好的方法可以从 application_Version 列中检索第二大值吗? I created this according to how i would do it in SQL, but it seems that Kusto is a bit different.
我根据我在 SQL 中的做法创建了这个,但 Kusto 似乎有点不同。
I hope you can help me fixing this and enlighten me and enhance my Kusto skills.我希望你能帮助我解决这个问题,启发我并提高我的 Kusto 技能。
Best regards, Maverick最好的问候,特立独行
latestVersion
is not a scalar. latestVersion
不是标量。 To make it scalar, you have to surround it with toscalar(...)
.要使其成为标量,您必须用
toscalar(...)
包围它。
In any case, if you want to find the top 2 items, there's a much more efficient way to do it:无论如何,如果你想找到前 2 个项目,有一种更有效的方法来做到这一点:
customEvents
| where client_OS contains "Android"
| top 2 by application_Version desc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.