SELECT sum(Calificacion )/count(CodPregunta) FROM tabla WHERE CodGrupoPregunta IN (SELECT CodGrupoPregunta FROM tabolagrupos) GROUP BY pregunta;