Your question is Rolling 7-Day System Error Average. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
You are given daily system error logs and asked to calculate a rolling 7-day average of errors for each day in the series. Use PostgreSQL-compatible SQL to return one row per calendar day with the daily error count and the 7-day trailing average, including days with zero errors. Do not use MySQL-only syntax.
| Column | Type | Description |
|---|---|---|
| error_idPK | INT | Primary key for each error event |
| occurred_at | TIMESTAMP | Timestamp when the error occurred |
| system_name | VARCHAR(100) | Name of the system that emitted the error |
| severity | VARCHAR(20) | Error severity level |