比较当前值与先前值之间的数据 – Kusto

huangapple go评论54阅读模式
英文:

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) &lt; humidity
| project id
英文:

You could use the prev() function.

For example:

T
| order by record_date asc
| where prev(humidity) &lt; humidity
| project id

huangapple
  • 本文由 发表于 2023年5月21日 10:19:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76298040.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定