Postgres Function/Trigger Avg
BEGIN UPDATE "item" 
    SET "score" = (select AVG("vote"."score") FROM "vote")     


Use it as follows:

create or replace function test (id int) returns void as 
$$ 
begin 
update employees 
set commission_pct=(select min(commission_pct) from employees) 
where employee_id= $1; 
end 
$$ LANGUAGE plpgsql VOLATILE; 

select test(198); --call function 


The process of aggregate functions is calculated after getting data set from data in table, we cannot use any calculating without selecting data from table first. In the above function is update column score* to AVG(score) but there is not data-set to calculate the AVG(score).