You work as a Data Analyst for Mark at MDFT Pro, a well-known training agency. MDFT Pro operates a KQL database that tracks utility meter readings across various training facilities. The database contains a table named Readings that stores meter reading data including city, area, meter reading values, and timestamps. Mark has asked you to create a KQL query that compares each meter reading value to the previous reading based on the timestamp, allowing the agency to monitor consumption patterns across their facilities. The expected output should show each reading alongside the previous reading and its timestamp for easy comparison.
| City | Area | MeterReading | Timestamp | PrevMeterReading | PrevTimestamp |
|---|---|---|---|---|---|
| Kansas | Area1 | 1500 | 2024-07-30 10:00:00 | ||
| Kansas | Area2 | 1520 | 2024-07-30 11:00:00 | 1500 | 2024-07-30 10:00:00 |
How should you complete the KQL query below to reproduce this output?
Readings
| filter City == "Kansas"
| sort by Timestamp
| _____________ PrevMeterReading = prev(MeterReading)
PrevTimestamp = prev(Timestamp)
| project City, Area, MeterReading, Timestamp, PrevMeterReading, PrevTimestamp
Choose the correct answer from the options below.
Explanations for each answer: