Write a SQL query to calculate a running total of daily sensor readings and compare it to the previous day at Keysight Technologies.
Use the sensor_readings table. Calculate results independently for each sensor, including days whose readings aggregate to zero or NULL.
sensor_id, reading_date, daily_reading, running_total, previous_day_reading, and change_from_previous_day.sensor_id and reading_date, and use NULL when no prior day exists or the comparison cannot be calculated.| Column | Type | Description |
|---|---|---|
| sensor_reading_idPK | INT | Unique identifier for a raw sensor reading |
| sensor_id | VARCHAR(20) | Keysight measurement sensor identifier |
| reading_date | DATE | Calendar date of the reading |
| reading_value | DECIMAL(10,2) | Sensor reading value |