Write a complex SQL query using window functions to identify consecutive days of sensor anomalies.
Use the sensor_readings table. Return only anomaly streaks containing at least two consecutive calendar days.
sensor_id, streak_start, streak_end, consecutive_dayssensor_id, then streak_start| Column | Type | Description |
|---|---|---|
| reading_idPK | INT | Unique sensor reading identifier |
| sensor_id | VARCHAR(20) | Sensor identifier |
| reading_date | DATE | Calendar date of the reading |
| anomaly_type | VARCHAR(30) | Detected anomaly category |
| anomaly_score | NUMERIC(5,2) | Severity score for the reading |
| is_anomaly | BOOLEAN | Whether the reading is classified as anomalous |