Avathon's industrial monitoring system stores sensor readings for registered machines. Write a PostgreSQL query that summarizes readings for active machines during March 1 through March 10, 2025.
Use RANGE BETWEEN INTERVAL '6 days' PRECEDING AND CURRENT ROW for the inclusive seven-day window. Preserve dates containing only NULL readings so the running total remains unchanged and the moving average excludes those NULL values.
| Column | Type | Description |
|---|---|---|
| machine_idPK | INTEGER | Unique machine identifier |
| machine_code | VARCHAR(20) | Avathon machine code |
| asset_name | VARCHAR(100) | Human-readable asset name |
| status | VARCHAR(20) | Current machine status |
| Column | Type | Description |
|---|---|---|
| reading_idPK | INTEGER | Unique sensor reading identifier |
| machine_id | INTEGER | Machine that produced the reading |
| reading_date | DATE | Calendar date of the reading |
| reading_value | NUMERIC(10,2) | Sensor measurement |