Your question is Ranking Customers with Window Functions. Start with the requirements and the two tables 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.
Entergy analysts need to compare customer energy consumption across service regions and billing months. Write a PostgreSQL query using the customers and energy_usage tables to rank customers by their total monthly usage within each Entergy region.
RANK() partitioned by region and month, with the highest usage receiving rank 1. Preserve ties with the same rank.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| region | VARCHAR(50) | Entergy service region |
| Column | Type | Description |
|---|---|---|
| usage_idPK | INT | Unique usage reading identifier |
| customer_id | INT | Customer identifier associated with the reading |
| usage_date | DATE | Date on which energy usage was recorded |
| kwh_used | NUMERIC(12,2) | Energy consumed in kilowatt-hours |