首页 > 解决方案 > 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 中搜索什么概念来进行这种操作。我可以获得不同的客户列表和不同的类型列表,但我不确定如何将两者结合起来,或者这是否是我应该做的!

任何线索都会有所帮助!

标签: azure-data-explorerkql

解决方案


使用summarize arg_max(...) by Type, Customer就可以了。

在此处查看更多关于 arg_max的信息。


推荐阅读