简体   繁体   English

如何在 Kusto 查询语言中使用“!contains”的 where 子句中使用存储在“let”中的 s skalar

[英]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.

相关问题 等效于 Splunk 在 Kusto 查询语言中的查找 - Equivalent of Splunk's lookup in Kusto Query Language 如何使用 Azure Kusto 查询语言 (KQL) 查询 Jmeter Graph,例如 Active Threads Over times - How to use Azure Kusto Query Language (KQL) to query Jmeter Graph such as Active Threads Over times Kusto 查询语言 - 如何准确获取前一天的日志 7 - Kusto query language - How to get exactly logs from previous day 7 在 ADX 表上分页。 如何跳过 kusto 查询语言中的记录 - Paging on ADX table. how to skip the records in kusto query language 使用 kusto 查询语言查找列等于字符串 A 或字符串 B 的所有记录 - Find all records where a column is either equal to string A or string B using kusto query language 使用 Kusto 查询语言的具有单个数字的图表 - A chart with a single number using Kusto Query Language 如何使用 Kusto 查询作为 Azure ML 的输入数据 - How to use Kusto query as input data to Azure ML 如何使用 Kusto 查询语言创建一个逻辑来计算一小时内相同 IP 地址的数量 - how to create a logic to count the number of the same IP address in an hour with Kusto Query Language 如何基于 kusto 查询(KQL)语言中的命名键从 Json 中获取值 - How to fetch the value from the Json based on Named key in kusto query(KQL) language 如何使用 Kusto 查询语言在 Azure 日志中显示具有多个自定义指标的时间表 - How do I display a timechart with more than one custom metric in Azure Logs with Kusto Query Language
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM