Your question is Window Functions for Top Customers. 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.
Pacific Gas and Electric needs a regional view of customer electricity consumption for 2025. Write a PostgreSQL query that identifies the top three customers by total usage within each PG&E service region.
usage_kwh during calendar year 2025.| Column | Type | Description |
|---|---|---|
| customer_idPK | INTEGER | Unique PG&E customer identifier |
| customer_name | VARCHAR(100) | Customer account name |
| region | VARCHAR(50) | PG&E service region |
| service_start_date | DATE | Date the customer's service began |
| Column | Type | Description |
|---|---|---|
| usage_idPK | INTEGER | Unique usage record identifier |
| customer_id | INTEGER | Referenced customer identifier |
| usage_date | DATE | Date of the electricity usage measurement |
| usage_kwh | NUMERIC(12,2) | Measured electricity usage in kilowatt-hours |