USE COLEGIUU
SELECT NmStud, PrenStud,
NotaMedie = (SELECT AVG(N.Nota) FROM [Notele] N WHERE N.idStudent = S.IdStudent)
FROM Student S
WHERE idStudent IN(SELECT idStudent FROM Notele GROUP BY idStudent)
NotaMedie是具有可计算值的临时列。我如何仅输出NotaMedie> 9的行?
您可以使用having
子句加入,聚合和过滤:
select s.NmStud, s.PrenStud, avg(n.Nota) NotaMedie
from student s
inner join notele n on n.idStudent = s.idStudent
group by s.NmStud, s.PrenStud
having avg(n.Nota) > 9