# Student(S#,Sname,Sage,Ssex) 学生表
# Course(C#,Cname,T#) 课程表
# SC(S#,C#,score) 成绩表
# Teacher(T#,Tname) 教师表
求一sql:
把“SC”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩;
# Course(C#,Cname,T#) 课程表
# SC(S#,C#,score) 成绩表
# Teacher(T#,Tname) 教师表
求一sql:
把“SC”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩;
# Course(C#,Cname,T#) 课程表
# SC(S#,C#,score) 成绩表
# Teacher(T#,Tname) 教师表
求一sql:
把“SC”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩;
update a set
a.score=b.score
from #SC a
join (select C#,avg(score) score from #SC group by C#) b
on a.C#=b.C#
join #Course c
on a.C#=c.C#
join #Teacher d
on c.T#=d.T# and d.Tname='叶平'
update
sc
set
sc.score = tt.avg_score
from t_sc sc,
(
select c_id , avg(score) avg_score from t_sc where c_id in(
select c.id from t_teacher t,t_course c where t.id = c.t_id and t.tname = '张老师'
)group by c_id
)tt
where tt.c_id = sc.c_id