Vamos analisar cada alternativa: (A) UPDATE ALUNO SET NotaGlobal = t.med FROM ALUNO a, (SELECT Matricula, AVG(nota) AS med FROM Registro WHERE Matricula IN (SELECT Matricula FROM ALUNO) GROUP BY Matricula ) AS t WHERE a.Matricula=t.Matricula; (B) UPDATE ALUNO SET NotaGlobal = t.med FROM ALUNO a, (SELECT Matricula, MED(nota) AS med FROM Registro WHERE Matricula IN (SELECT Matricula FROM ALUNO) GROUP BY Matricula ) AS t WHERE a.Matricula = t.Matricula; (C) UPDATE ALUNO SET NotaGlobal = t.med FROM ALUNO a, (SELECT Matricula, MED(nota) AS med FROM Registro WHERE Matricula IN (SELECT Matricula FROM ALUNO)) AS t WHERE a.Matricula=t.Matricula; (D) UPDATE ALUNO SET NotaGlobal = t.med FROM ALUNO a, (SELECT Matricula, AVG(nota) AS med FROM Registro WHERE Matricula IN (SELECT Matricula FROM ALUNO)) AS t WHERE a.Matricula=t.Matricula; A alternativa correta é a (A) UPDATE ALUNO SET NotaGlobal = t.med FROM ALUNO a, (SELECT Matricula, AVG(nota) AS med FROM Registro WHERE Matricula IN (SELECT Matricula FROM ALUNO) GROUP BY Matricula ) AS t WHERE a.Matricula=t.Matricula;. Este comando SQL atualiza o atributo NotaGlobal na tabela ALUNO com a média das notas de cada aluno.
Para escrever sua resposta aqui, entre ou crie uma conta
Compartilhar