diff --git a/function_total_energy_by_day_and_device.sql b/function_total_energy_by_day_and_device.sql index a144f26..8302bcf 100644 --- a/function_total_energy_by_day_and_device.sql +++ b/function_total_energy_by_day_and_device.sql @@ -69,7 +69,9 @@ create or replace function total_energy(p_start_day date, p_end_say date) v_deviceid text; v_result rt_totalizer_result%rowtype; begin - for v_deviceid in select distinct deviceid from power_measurement_t loop + for v_deviceid in select distinct deviceid + from power_measurement_t + loop v_day := p_start_day; loop select energy