gpt4 book ai didi

azure-log-analytics - 如何编写 Kusto 查询以仅选择在一个字段中具有唯一值的行

转载 作者:行者123 更新时间:2023-12-03 18:40:56 27 4
gpt4 key购买 nike

有这个输入:

let t1 = datatable(id:string, col1:string, col2:string)
[
'1', 'col1_1', 'col2_1',
'2', 'col1_2', 'col2_2',
'3', 'col1_3', 'col2_3',
'4', 'col1_4', 'col2_4',
'1', 'col1_1', 'col2_11',
];
t1
| distinct id, col1

我需要一个查询,该查询将仅选择“id”字段中具有唯一值的行。我知道有两种可能的输出:

输出 1:
'1', 'col1_1', 'col2_1',
'2', 'col1_2', 'col2_2',
'3', 'col1_3', 'col2_3',
'4', 'col1_4', 'col2_4',

输出 2:
'2', 'col1_2', 'col2_2',
'3', 'col1_3', 'col2_3',
'4', 'col1_4', 'col2_4',
'1', 'col1_11', 'col2_11',

最佳答案

您可以使用 any() 聚合函数根据 'id' 列中的唯一值获取 col1 和 col2 值。

let t1 = datatable(id:string, col1:string, col2:string)
[
'1', 'col1_1', 'col2_1',
'2', 'col1_2', 'col2_2',
'3', 'col1_3', 'col2_3',
'4', 'col1_4', 'col2_4',
'1', 'col1_1', 'col2_11',
];
t1
| summarize any(col1), any(col2) by id

关于azure-log-analytics - 如何编写 Kusto 查询以仅选择在一个字段中具有唯一值的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52844757/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com