azure-data-explorer - Kusto / KQL 查询获取不同的输出,然后在后续查询中使用
问题描述
我在表中有以下数据customMetrics
:
| date | customDimension | Type | value |
| -----------------------------------------------------|
| 01-03-2021 | {"customer":"a"} | Transactions | 12 |
| 01-03-2021 | {"customer":"a"} | Value | 784 |
| 01-03-2021 | {"customer":"c"} | Transactions | 733 |
| 01-03-2021 | {"customer":"b"} | Transactions | 7 |
| 01-03-2021 | {"customer":"c"} | Value | 5 |
| 01-03-2021 | {"customer":"b"} | Value | 85 |
| 01-03-2021 | {"customer":"a"} | Transactions | 50 |
| 01-03-2021 | {"customer":"a"} | Value | 73 |
| 01-03-2021 | {"customer":"c"} | Value | 3 |
| 01-03-2021 | {"customer":"a"} | Transactions | 13 |
| 01-03-2021 | {"customer":"a"} | Value | 237 |
| 01-03-2021 | {"customer":"c"} | Transactions | 3 |
| 01-03-2021 | {"customer":"b"} | Transactions | 575 |
| 01-03-2021 | {"customer":"b"} | Value | 85 |
| 01-03-2021 | {"customer":"b"} | Transactions | 43 |
| 01-03-2021 | {"customer":"b"} | Value | 85 |
| 01-03-2021 | {"customer":"c"} | Value | 789 |
我正在尝试编写一个查询,该查询将为每个客户找到每种类型的每个值的最大值,例如:
| date | customer | Type | value |
| ---------------------------------------------|
| 01-03-2021 | a | Transactions | 50 |
| 01-03-2021 | a | Value | 784 |
| 01-03-2021 | b | Transactions | 575 |
| 01-03-2021 | b | Value | 85 |
| 01-03-2021 | c | Transactions | 733 |
| 01-03-2021 | c | Value | 789 |
我很难知道在 kusto 中搜索什么概念来进行这种操作。我可以获得不同的客户列表和不同的类型列表,但我不确定如何将两者结合起来,或者这是否是我应该做的!
任何线索都会有所帮助!
解决方案
使用summarize arg_max(...) by Type, Customer
就可以了。
在此处查看更多关于 arg_max的信息。
推荐阅读
- python - 读取字典并写入文本文件
- sql - 如何在数据库中存储类似货币的大数据
- actionscript-3 - 编写自定义轻松
- python - AttributeError:模块“django.contrib.auth.views”没有属性“LoginView”
- ruby-on-rails - 嵌套属性的 Rails 自定义错误消息
- python - 打印值 0-255 如何取决于 ASCII 码
- java - 在 2D Array 中搜索另一个 1D Array 的字符串,然后将它们放入一个新的 2D 中
- gitlab-ci-runner - 为多个 GitLab 存储库注册相同的运行器
- python - 使用重复块解析文件中的垂直文本
- python - 如何在不使用“with”语法的情况下在 python 中打开 csv 文件?