You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATE OR REPLACEFUNCTIONf_grp_prod(text)
RETURNS TABLE (
name text
, result1 double precision
, result2 double precision)
LANGUAGE plpgsql STABLE
AS
$$
DECLARE
r mytable%ROWTYPE;
_round integer;
BEGIN-- init vars
name := $1;
result2 :=1; -- abuse result2 as temp var for convenience
FOR r INSELECT*FROM mytable m
WHEREm.name= name
ORDER BY m.round
LOOP
IF r.round<> _round THEN -- save result1 before 2nd round
result1 := result2;
result2 :=1;
END IF;
result2 := result2 * (1-r.val/100);
_round :=r.round;
END LOOP;
RETURN NEXT;
END;
$$;
SELECT*FROM foo;
The identifier only returns one function instead of two.
The text was updated successfully, but these errors were encountered:
Test query:
The identifier only returns one function instead of two.
The text was updated successfully, but these errors were encountered: