How would you design a SQL query using window functions to compare each data center's monthly power usage against its prior month and rolling 3-month average?
Assume raw power readings may contain multiple records per data center and month, and some months may have no readings. Return calendar months across the overall reading period, preserving data centers without readings.
center_id, center_name, usage_month, monthly_power_kwh, prior_month_kwh, and rolling_3_month_avg_kwh.center_id, then usage_month ascending.| Column | Type | Description |
|---|---|---|
| center_idPK | INT | Unique data center identifier |
| center_code | VARCHAR(20) | Short data center code |
| center_name | VARCHAR(100) | Data center display name |
| Column | Type | Description |
|---|---|---|
| reading_idPK | INT | Unique power reading identifier |
| center_id | INT | Referenced data center |
| reading_at | TIMESTAMP | Timestamp of the power reading |
| power_kwh | NUMERIC(12,2) | Energy consumed in kilowatt-hours |