[英]Getting only unique values within a category in Kusto Query Language (Azure Monitor Logs)
I have data in this format:我有这种格式的数据:
Category Session_ID Step_Name
A 100 1
A 100 2
A 200 1
A 200 1 <--
A 200 1 <--
A 200 2
B 300 1
B 300 1 <--
I need to remove the duplicate values of step names within each Session_ID .我需要删除每个 Session_ID中步骤名称的重复值。 For example in ID = 200, there are three '1's which need to be changed to one '1', so the final data looks like:
例如ID = 200,有3个'1'需要改成1个'1',所以最终数据如下:
Category Session_ID Step_Name
A 100 1
A 100 2
A 200 1
A 200 2
B 300 1
You should use distinct operator in your case:您应该在您的情况下使用distinct 运算符:
your_table
| distinct Category, Session_ID, Step_Name
then you can get the expected output like below, it works at my side:然后你可以得到预期的 output 如下所示,它在我身边工作:
Category Session_ID Step_Name
A 100 1
A 100 2
A 200 1
A 200 2
B 300 1
And for your question in the comment, if you use the above query, the record like "A 100 1" would consider as one entity, and only if there are 2 or more exact same record like "A 100 1" would remain only 1 record if using distinct.对于您在评论中的问题,如果您使用上述查询,则“A 100 1”之类的记录将被视为一个实体,并且只有当有 2 个或更多完全相同的记录(例如“A 100 1”)时,才会仅保留 1如果使用 distinct 则记录。
And if there is another record like "B 100 1", then the both 2 records "A 100 1" and "B 100 1" would remain.如果有另一条记录,如“B 100 1”,则两条记录“A 100 1”和“B 100 1”都将保留。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.