Kusto:在固定大小的固定箱中汇总一列中具有实数值的不同行
Kusto: Summarize different rows having real number values in a column in fixed bins of fixed sizes
我有 3 个 table 是这样的:-
Table A:
------
Delay
------
2.3
4.5
6.7
12.36
Table B:
-------
Delay
-------
12.31
74.556
16.744
Table C:
-------
Delay
-------
2.35
8.5
637.3
5.36
1.23
我想加入他们并在大小为(<0.5、>0.5 和<1、>1 和<1.5、>1.5 和<2、>2)的容器中延迟,只有这些固定大小,仅此而已.
我想要这样的 table:-
Delay | Source | Count
-----------------------
<0.5 | A | 6
<0.5 | B | 16
<0.5 | C | 26
0.5-1 | A | 25
0.5-1 | B | 25
0.5-1 | C | 25
1-1.5 | A | 6
1-1.5 | B | 6
1-1.5 | C | 6
1.5-2 | A | 2
1.5-2 | B | 2
1.5-2 | C | 2
>2 | A | 36
>2 | B | 36
>2 | C | 36
对此最有效的查询是什么?
给你:
union withsource=Source TableA, TableB, TableC
| extend Delay = case(
d < 0.5, "A <0.5",
d >= 0.5 and d < 1, "B 0.5-1",
d >= 0.5 and d < 1, "C 0.5-1",
d >= 1 and d < 1.5, "D 1-1.5",
d >= 1.5 and d < 2, "E 1.5-2",
"F >2")
| summarize Count = count() by Source, Delay
| project-reorder Delay, Source, Count
| order by Delay asc, Source asc
| extend Delay = substring(Delay, 2)
达到你想要的效果所需的“技巧”是:
- 使用
union withsource=Source
- 这将联合你的三个 table 和一个名为 Source
的新列将包含原始 table 的名称
case
将划分为桶(请注意,我在所有选项中添加了一个字母,以便轻松对桶进行排序)- 然后我在查询的最后一行删除了这个字母
project-reorder
以您请求的顺序显示输出列
order by
对记录进行排序以满足您的需要(这是我在 case
中添加 A-F 字母的这一行 - 这确保根据您的要求进行排序)
我有 3 个 table 是这样的:-
Table A:
------
Delay
------
2.3
4.5
6.7
12.36
Table B:
-------
Delay
-------
12.31
74.556
16.744
Table C:
-------
Delay
-------
2.35
8.5
637.3
5.36
1.23
我想加入他们并在大小为(<0.5、>0.5 和<1、>1 和<1.5、>1.5 和<2、>2)的容器中延迟,只有这些固定大小,仅此而已. 我想要这样的 table:-
Delay | Source | Count
-----------------------
<0.5 | A | 6
<0.5 | B | 16
<0.5 | C | 26
0.5-1 | A | 25
0.5-1 | B | 25
0.5-1 | C | 25
1-1.5 | A | 6
1-1.5 | B | 6
1-1.5 | C | 6
1.5-2 | A | 2
1.5-2 | B | 2
1.5-2 | C | 2
>2 | A | 36
>2 | B | 36
>2 | C | 36
对此最有效的查询是什么?
给你:
union withsource=Source TableA, TableB, TableC
| extend Delay = case(
d < 0.5, "A <0.5",
d >= 0.5 and d < 1, "B 0.5-1",
d >= 0.5 and d < 1, "C 0.5-1",
d >= 1 and d < 1.5, "D 1-1.5",
d >= 1.5 and d < 2, "E 1.5-2",
"F >2")
| summarize Count = count() by Source, Delay
| project-reorder Delay, Source, Count
| order by Delay asc, Source asc
| extend Delay = substring(Delay, 2)
达到你想要的效果所需的“技巧”是:
- 使用
union withsource=Source
- 这将联合你的三个 table 和一个名为Source
的新列将包含原始 table 的名称
case
将划分为桶(请注意,我在所有选项中添加了一个字母,以便轻松对桶进行排序)- 然后我在查询的最后一行删除了这个字母project-reorder
以您请求的顺序显示输出列order by
对记录进行排序以满足您的需要(这是我在case
中添加 A-F 字母的这一行 - 这确保根据您的要求进行排序)