Jelajahi Sumber

fix(docs): add tutorial for when function

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>
Jianxiang Ran 2 tahun lalu
induk
melakukan
2b21bc30b9

+ 1 - 1
docs/en_US/sqls/built-in_functions.md

@@ -221,7 +221,7 @@ lag(temperature) OVER (PARTITION BY deviceId)
 Example function call to calculate duration of events:  ts is timestamp, and statusCode1 and statusCode2 are device status in the same event
 
 ```text
-ts - lag(ts, 1, ts) OVER (WHEN statusCode1 != statusCode2)
+select lag(Status) as Status, ts - lag(ts, 1, ts) OVER (WHEN had_changed(true, statusCode)) as duration from demo
 ```
 
 ## Other Functions

+ 1 - 1
docs/zh_CN/sqls/built-in_functions.md

@@ -213,7 +213,7 @@ lag(temperature) OVER (PARTITION BY deviceId)
 示例3:ts为时间戳,获取设备状态 statusCode1 和 statusCode2 不相等持续时间
 
 ```text
-ts - lag(ts, 1, ts) OVER (WHEN statusCode1 != statusCode2)
+select lag(Status) as Status, ts - lag(ts, 1, ts) OVER (WHEN had_changed(true, statusCode)) as duration from demo
 ```
 
 ## 其它函数