Omaha Public Power District (OPPD) needs a customer-level view of recent electricity consumption. Write a PostgreSQL query that first consolidates readings recorded on the same date, then calculates each customer's rolling calendar-based 7-day average usage.
customers to energy_usage and return only usage associated with a known customer.AVG.| Column | Type | Description |
|---|---|---|
| customer_idPK | INTEGER | Unique OPPD customer identifier |
| customer_name | VARCHAR(100) | Customer name |
| Column | Type | Description |
|---|---|---|
| usage_idPK | INTEGER | Unique usage reading identifier |
| customer_id | INTEGER | References customers.customer_id |
| usage_date | DATE | Date of the usage reading |
| kwh_used | NUMERIC(10,2) | Energy consumed in kilowatt-hours |