英文:
Compare data between current value and previous value - Kusto
问题
想要找到湿度大于前一天湿度的行的id值。
datatable(id:int, recorddate:datetime, humidity:real)
[
1, datetime(2022-11-01), 10.0,
2, datetime(2022-11-02), 12.0,
3, datetime(2022-11-03), 15.0,
4, datetime(2022-11-04), 18.0,
5, datetime(2022-11-05), 20.0,
6, datetime(2022-11-06), 22.0,
7, datetime(2022-11-07), 19.0,
8, datetime(2022-11-08), 16.0,
9, datetime(2022-11-09), 14.0,
10, datetime(2022-11-10), 11.0,
];
期望的回复:
id
2
3
4
5
6
上述id的值大于其前一行的值。
<details>
<summary>英文:</summary>
I want to find the id value of rows whose humidity
is greater than the previous day humidity.
datatable(id:int, recorddate:datetime, humidity:real)
[
1, datetime(2022-11-01), 10.0,
2, datetime(2022-11-02), 12.0,
3, datetime(2022-11-03), 15.0,
4, datetime(2022-11-04), 18.0,
5, datetime(2022-11-05), 20.0,
6, datetime(2022-11-06), 22.0,
7, datetime(2022-11-07), 19.0,
8, datetime(2022-11-08), 16.0,
9, datetime(2022-11-09), 14.0,
10, datetime(2022-11-10), 11.0,
];
desired response:
id
2
3
4
5
6
Above ids have values greater than their previous row value.
</details>
# 答案1
**得分**: 1
你可以使用[`prev()`函数](https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/prevfunction)。
例如:
```kusto
T
| order by record_date asc
| where prev(humidity) < humidity
| project id
英文:
You could use the prev()
function.
For example:
T
| order by record_date asc
| where prev(humidity) < humidity
| project id
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论