需要使用 Kusto 查询语言 (KQl) 实现以下输出
Need to achieve the below output using Kusto Query language(KQl)
示例数据。我们预计每天都会收到总数量的产品。
TimeStamp
Product Desc
Product Code
Available count
2022-01-02T09:00:00Z
Berries
111
10
2022-01-02T09:00:00Z
Chocolate
222
20
2022-01-02T09:00:00Z
Mayo
333
30
2022-01-03T09:00:00Z
Berries
111
15
2022-01-03T09:00:00Z
Chocolate
222
22
2022-01-04T09:00:00Z
Berries
111
30
如果那天没有收到产品,我必须将最后收到产品的日期显示为当天。
TimeStamp
Product Desc
Product Code
Available count
2022-01-03T09:00:00Z
Berries
111
15
2022-01-03T09:00:00Z
Chocolate
222
22
2022-01-03T09:00:00Z
Mayo
333
30
2022-01-04T09:00:00Z
Berries
111
30
2022-01-04T09:00:00Z
Chocolate
222
22
2022-01-04T09:00:00Z
Mayo
333
30
datatable (['TimeStamp']:datetime,['Product Desc']:string,['Product Code']:int,['Available count']:int)
[
'2022-01-02T09:00:00Z' ,'Berries' ,111 ,10
,'2022-01-02T09:00:00Z' ,'Chocolate' ,222 ,20
,'2022-01-02T09:00:00Z' ,'Mayo' ,333 ,30
,'2022-01-03T09:00:00Z' ,'Berries' ,111 ,15
,'2022-01-03T09:00:00Z' ,'Chocolate' ,222 ,22
,'2022-01-04T09:00:00Z' ,'Berries' ,111 ,30
]
| summarize arg_max(['TimeStamp'], *) by ['Product Code']
Product Code
TimeStamp
Product Desc
Available count
333
2022-01-02T09:00:00Z
Mayo
30
222
2022-01-03T09:00:00Z
Chocolate
22
111
2022-01-04T09:00:00Z
Berries
30
示例数据。我们预计每天都会收到总数量的产品。
TimeStamp | Product Desc | Product Code | Available count |
---|---|---|---|
2022-01-02T09:00:00Z | Berries | 111 | 10 |
2022-01-02T09:00:00Z | Chocolate | 222 | 20 |
2022-01-02T09:00:00Z | Mayo | 333 | 30 |
2022-01-03T09:00:00Z | Berries | 111 | 15 |
2022-01-03T09:00:00Z | Chocolate | 222 | 22 |
2022-01-04T09:00:00Z | Berries | 111 | 30 |
如果那天没有收到产品,我必须将最后收到产品的日期显示为当天。
TimeStamp | Product Desc | Product Code | Available count |
---|---|---|---|
2022-01-03T09:00:00Z | Berries | 111 | 15 |
2022-01-03T09:00:00Z | Chocolate | 222 | 22 |
2022-01-03T09:00:00Z | Mayo | 333 | 30 |
2022-01-04T09:00:00Z | Berries | 111 | 30 |
2022-01-04T09:00:00Z | Chocolate | 222 | 22 |
2022-01-04T09:00:00Z | Mayo | 333 | 30 |
datatable (['TimeStamp']:datetime,['Product Desc']:string,['Product Code']:int,['Available count']:int)
[
'2022-01-02T09:00:00Z' ,'Berries' ,111 ,10
,'2022-01-02T09:00:00Z' ,'Chocolate' ,222 ,20
,'2022-01-02T09:00:00Z' ,'Mayo' ,333 ,30
,'2022-01-03T09:00:00Z' ,'Berries' ,111 ,15
,'2022-01-03T09:00:00Z' ,'Chocolate' ,222 ,22
,'2022-01-04T09:00:00Z' ,'Berries' ,111 ,30
]
| summarize arg_max(['TimeStamp'], *) by ['Product Code']
Product Code | TimeStamp | Product Desc | Available count |
---|---|---|---|
333 | 2022-01-02T09:00:00Z | Mayo | 30 |
222 | 2022-01-03T09:00:00Z | Chocolate | 22 |
111 | 2022-01-04T09:00:00Z | Berries | 30 |