This view aggregates actual, previous and target energy usage in kWh for City buildings (where Site Type = Building) and calculates the percentage change.
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 `building_flag` = 'Y'
GROUP BY
`month_date`
ORDER BY `month_date` desc