Aggregates current, previous and target energy usage for city owned facilities where site type = Drinking Water Treatment & Distribution.
SELECT
month_date,
sum(`kwh`),
sum(`previous_kwh_usage`),
sum(`target_kwh`),
case(`sum_kwh` > 0, (`sum_kwh` - `sum_previous_kwh_usage`) / `sum_previous_kwh_usage`) AS `total_percent_change`,
case(`sum_kwh` > 0, (`sum_kwh` - `sum_target_kwh`) / `sum_target_kwh`) AS `target_percent_change`
WHERE `site_type` IN ('Drinking Water Treatment & Distribution')
GROUP BY
`month_date`
ORDER BY `month_date` desc