2
I need to sum up all the gap differences that meet the Where condition. There is only one however, if there is no end_date on this line, I need to take the current time and do the calculation with the current time instead of end_date.
CREATE OR REPLACE FUNCTION total_paused_time (v_id Integer)
RETURNS Interval
as $$
DECLARE @aux integer
select sum(@aux),
case when end_date = null then @aux := now() - start_date
else then @aux := end_date - start_date
end
from called_pause where called_id = v_id and internal = false;
$$ LANGUAGE SQL;
And what mistake you’re facing ?
– gmsantos
The version of postgresql that I use, does not accept the use of @variavel, so I was having a syntax error, I ended up solving the problem differently and published the answer below.
– ramoncs11
You published a syntax error and a vague problem... and you yourself answered... it’s still hard to understand the usefulness of this.
– Peter Krauss