CREATE OR REPLACE FUNCTION compute_avarage_grade (p_class_id IN enrollments.class_id%type)
RETURN NUMBER
IS
v_avg enrollments.final_numeric_grade%type;
begin
select avg(final_numeric_grade)
into v_avg
from enrollments
where class_id=p_class_id;
RETURN NVL(v_avg,0));
end;