update a set sumgrade=b.stugrade
from student a
inner join
(select StudentID,SUM(stugrade) as stugrade
from grade
group by StudentID
)b on a.StudentID=b.StudentID
select * from student
------解决方案-------------------- left join查询:左边全部显示;右边符合条件就显示,不符合条件则为null.
right join查询:右边全部显示;左边符合条件就显示,不符合条件则为null.