作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有了下表和 Kusto 查询,我如何才能获得包含 Purchase 列的结果?
let ProductsTable = datatable(Supplier: string, Fruit: string, Price: int, Purchase: datetime)
[
'Contoso', 'Grapes', 220, datetime(2018-10-01 01:00),
'Fabrikam', 'Lemons', 31, datetime(2018-10-01 02:00),
'Contoso', 'Lemons', 29, datetime(2018-10-02 03:00),
'Contoso', 'Grapes', 210, datetime(2018-10-02 04:00),
'Fabrikam', 'Lemons', 30, datetime(2018-10-03 05:00),
'Contoso', 'Bananas', 12, datetime(2018-10-03 06:00),
'Contoso', 'Bananas', 12, datetime(2018-10-04 07:00),
'Contoso', 'Lemons', 29, datetime(2018-10-04 08:00),
'Contoso', 'Grapes', 200, datetime(2018-10-05 09:00),
];
ProductsTable
| summarize Price = min(Price) by Supplier, Fruit
| order by Supplier asc, Fruit asc, Price asc
结果
Contoso Bananas 12
Contoso Grapes 200
Contoso Lemons 29
Fabrikam Lemons 30
期望的结果
Contoso Bananas 12 2018-10-03 06:00
Contoso Grapes 200 2018-10-05 09:00
Contoso Lemons 29 2018-10-02 03:00
Fabrikam Lemons 30 2018-10-03 05:00
我知道可能有多个结果,例如对于 Contoso-Bananas-12 我们可以有以下任何一个
最佳答案
尝试使用 arg_min()
:https://learn.microsoft.com/en-us/azure/kusto/query/arg-min-aggfunction
let ProductsTable = datatable(Supplier: string, Fruit: string, Price: int, Purchase: datetime)
[
'Contoso', 'Grapes', 220, datetime(2018-10-01 01:00),
'Fabrikam', 'Lemons', 31, datetime(2018-10-01 02:00),
'Contoso', 'Lemons', 29, datetime(2018-10-02 03:00),
'Contoso', 'Grapes', 210, datetime(2018-10-02 04:00),
'Fabrikam', 'Lemons', 30, datetime(2018-10-03 05:00),
'Contoso', 'Bananas', 12, datetime(2018-10-03 06:00),
'Contoso', 'Bananas', 12, datetime(2018-10-04 07:00),
'Contoso', 'Lemons', 29, datetime(2018-10-04 08:00),
'Contoso', 'Grapes', 200, datetime(2018-10-05 09:00),
];
ProductsTable
| summarize Price = arg_min(Price, *) by Supplier, Fruit
| order by Supplier asc, Fruit asc, Price asc
关于azure-log-analytics - 库斯托 : How can I get the value from the column that doesn't participate in a SUMMARIZE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54411331/
我是一名优秀的程序员,十分优秀!