我有三张这样的桌子:-
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),只有这些固定的大小,仅此而已。我要这样的桌子:-
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对此最有效的查询是什么?
发布于 2021-03-02 09:16:53
给你:
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)达到你想要的目的所需要的“技巧”是:
table
case union withsource=Source --这将合并您的三个表,并且一个名为Source的新列将包含原始project-reorder的最后一行删除这封信,按照您requestedorder by的顺序显示输出列,以便对记录进行排序以满足您的需要(这一行是我在case中添加的A字母--这确保根据您要求的内容进行排序)https://stackoverflow.com/questions/66435190
复制相似问题