Your question is SQL for Top Energy Regions. Start with the requirements and the three 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.
Write a SQL query to find the top three energy-consuming regions per month from a transactional dataset.
Use the supplied region, meter, and transaction data. Include only posted transactions with non-null, non-negative consumption and a recorded timestamp. Ties at the third rank should be included.
month_start, region_name, total_kwh, and energy_rank.month_start, energy_rank, then region_name.| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique region identifier |
| region_name | VARCHAR(100) | Region name |
| Column | Type | Description |
|---|---|---|
| meter_idPK | INT | Unique meter identifier |
| region_id | INT | Region containing the meter |
| meter_status | VARCHAR(30) | Operational status of the meter |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| meter_id | INT | Meter reporting the consumption |
| recorded_at | TIMESTAMP | Timestamp when consumption was recorded |
| consumed_kwh | DECIMAL(12,2) | Energy consumption in kilowatt-hours |
| status | VARCHAR(30) | Transaction processing status |