你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
使用 “版本 ”下拉列表切换服务。 了解有关导航的详细信息。
适用于: ✅ Microsoft Fabric ✅ Azure 数据资源管理器 ✅ Azure Monitor ✅ Microsoft Sentinel
返回指定行中特定列的值。 指定的行与序列化行集中的当前行存在指定的偏移量。
语法
prev(
列, [ offset ], [ default_value ] )
详细了解语法约定。
参数
| 客户 | 类型 | 必需 | 说明 |
|---|---|---|---|
| column | string |
✔️ | 要从中获取值的列。 |
| offset | int |
行中向后的偏移量。 默认值为 1。 | |
| default_value | 标量 (scalar) | 当前面没有可从中获取值的行时要使用的默认值。 默认值为 null。 |
示例
基于相邻行之间的比较筛选数据
以下查询返回显示调用 sensor-9 之间的间隔超过四分之一秒的行。
TransformedSensorsData
| where SensorName == 'sensor-9'
| sort by Timestamp asc
| extend timeDiffInMilliseconds = datetime_diff('millisecond', Timestamp, prev(Timestamp, 1))
| where timeDiffInMilliseconds > 250
输出
| 时间戳 | SensorName | 值 | PublisherId | MachineId | timeDiff |
|---|---|---|---|---|---|
| 2022-04-13T00:58:53.048506Z | sensor-9 | 0.39217481975439894 | fdbd39ab-82ac-4ca0-99ed-2f83daf3f9bb | M100 | 251 |
| 2022-04-13T01:07:09.63713Z | sensor-9 | 0.46645392778288297 | e3ed081e-501b-4d59-8e60-8524633d9131 | M100 | 313 |
| 2022-04-13T01:07:10.858267Z | sensor-9 | 0.693091598493419 | 278ca033-2b5e-4f2c-b493-00319b275aea | M100 | 254 |
| 2022-04-13T01:07:11.203834Z | sensor-9 | 0.52415808840249778 | 4ea27181-392d-4947-b811-ad5af02a54bb | M100 | 331 |
| 2022-04-13T01:07:14.431908Z | sensor-9 | 0.35430645405452 | 0af415c2-59dc-4a50-89c3-9a18ae5d621f | M100 | 268 |
| ... | ... | ... | ... | ... | ... |
基于相邻行之间的比较执行聚合
以下查询计算调用 sensor-9 之间的平均时间差(以毫秒为单位)。
TransformedSensorsData
| where SensorName == 'sensor-9'
| sort by Timestamp asc
| extend timeDiffInMilliseconds = datetime_diff('millisecond', Timestamp, prev(Timestamp, 1))
| summarize avg(timeDiffInMilliseconds)
输出
| avg_timeDiffInMilliseconds |
|---|
| 30.726900061254298 |
使用上一行中的数据扩展行
在以下查询中,作为使用 serialize 运算符完成的序列化的一部分,一个新列 previous_session_type 将被添加,其中包含上一行中的数据。 由于在第一个会话之前没有会话,因此第一行中的列为空。
ConferenceSessions
| where conference == 'Build 2019'
| serialize previous_session_type = prev(session_type)
| project time_and_duration, session_title, session_type, previous_session_type
输出
| time_and_duration | session_title | session_type | previous_session_type |
|---|---|---|---|
| 星期一,5 月 6 日上午 8:30-10:00 | 愿景主题 - 萨蒂亚·纳德拉 | Keynote | |
| 星期一,5 月 6 日,下午 1:20-1:40 | Azure 数据资源管理器:高级时序分析 | Expo Session | Keynote |
| 星期一,5 月 6 日,下午 2:00-3:00 | Azure 的数据平台 - 在 Pbyte 规模上为新式应用程序和云规模分析提供支持 | Breakout | Expo Session |
| 星期一,5 月 6 日,下午 4:00-4:20 | FABRIC 如何使用 Azure 数据服务 | Expo Session | Breakout |
| 星期一,5月6日,6:50 - 晚上7:10 | Azure 数据资源管理器:作 ML 模型 | Expo Session | Expo Session |
| ... | ... | ... | ... |