Given a database of smart meter readings with irregular timestamps, write a query to find the average hourly consumption per user.
Use the supplied user and meter reading data. Treat each user's total consumption within an hour as that hour's consumption, then calculate the average across that user's observed hours. Include users without valid readings with a NULL average.
user_id, user_name, and average_hourly_consumption.user_id ascending, and round the average to two decimal places.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique identifier for the user |
| user_name | VARCHAR(100) | Display name of the user |
| Column | Type | Description |
|---|---|---|
| reading_idPK | INT | Unique identifier for the meter reading |
| user_id | INT | User associated with the reading |
| reading_timestamp | TIMESTAMP | Timestamp when the consumption was recorded |
| consumption_kwh | NUMERIC(10,2) | Energy consumed in kilowatt-hours |