Amigo, tambien he probado con esto 
     
Código MySQL:
Ver original-  -- Cargo la Variable con la Cantidad de Registros   
- -- Luego Tu codigo del If                   
-                   
-            final.idalumno= NEW.idalumno,  
-            final.califnum= avg_alumno 
-      WHERE-  final.idalumno =- NEW.idalumno ;
 
- // 
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE avg INT(11);
  SET avg_alumno = (SELECT AVG(califnum) FROM final WHERE ' at line 6