有四张表 student(s#,sname,sage,sex)学生表,Course(c#,cname,t#)课程表,SC(s#,c#,score)成绩表,
有四张表student(s#,sname,sage,sex)学生表,Course(c#,cname,t#)课程表,SC(s#,c#,score)成绩表,teacher(t...
有四张表 student(s#,sname,sage,sex)学生表,Course(c#,cname,t#)课程表,SC(s#,c#,score)成绩表,teacher(t#,tname)教师表
1,查询所有同学的学号,姓名,选课数,总成绩
2,查询至少学过学号为“001”同学所有一门课的其它同学学号和姓名
3,把SC表中“叶平”老师教的课的成绩都更改为此课程的平均成绩
4,删除学习“叶平”老师的SC表记录
答案正确着另外在加50分 在线等!!!
有四张表 student(sno,sname,sage,sex)学生表,Course(cno,cname,t#)课程表,SC(sno,cno,score)成绩表,teacher(tno,tname)教师表
sno cno tno分别代表学生编号 课程编号 教师编号 展开
1,查询所有同学的学号,姓名,选课数,总成绩
2,查询至少学过学号为“001”同学所有一门课的其它同学学号和姓名
3,把SC表中“叶平”老师教的课的成绩都更改为此课程的平均成绩
4,删除学习“叶平”老师的SC表记录
答案正确着另外在加50分 在线等!!!
有四张表 student(sno,sname,sage,sex)学生表,Course(cno,cname,t#)课程表,SC(sno,cno,score)成绩表,teacher(tno,tname)教师表
sno cno tno分别代表学生编号 课程编号 教师编号 展开
3个回答
展开全部
全部通过测试-----
第一题
select a.sno,count(a.sno) as 选课数,Sum(c.score) as 总成绩
from student as a,course as b,SC as c
where a.sno=c.sno and b.cno=c.cno
group by a.sno
第二题
select sno,sname from student
where sno in(
select distinct(d.sno)
from student as d,sc as e
where
d.sno=e.sno and e.sno<>'001' and
e.cno in
(
select b.cno
from student as a,course as b,SC as c
where a.sno=c.sno and b.cno=c.cno and a.sno='001'
))
第三题
update sc
set score=(select e.cavgScore from(
select cno as classno,avg(score) as cavgScore
from sc
where cno in(
select cno
from course as a,teacher as b
where tname='叶平')
group by cno) as e where classno=cno)
第四题
delete from sc
where sc.cno in
(
select a.cno
from course as a,teacher as b
where a.tno=b.tno and b.tname='叶平'
)
第一题
select a.sno,count(a.sno) as 选课数,Sum(c.score) as 总成绩
from student as a,course as b,SC as c
where a.sno=c.sno and b.cno=c.cno
group by a.sno
第二题
select sno,sname from student
where sno in(
select distinct(d.sno)
from student as d,sc as e
where
d.sno=e.sno and e.sno<>'001' and
e.cno in
(
select b.cno
from student as a,course as b,SC as c
where a.sno=c.sno and b.cno=c.cno and a.sno='001'
))
第三题
update sc
set score=(select e.cavgScore from(
select cno as classno,avg(score) as cavgScore
from sc
where cno in(
select cno
from course as a,teacher as b
where tname='叶平')
group by cno) as e where classno=cno)
第四题
delete from sc
where sc.cno in
(
select a.cno
from course as a,teacher as b
where a.tno=b.tno and b.tname='叶平'
)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个好像是面试题,我面试的时候有这样类似的题,当时就晕了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你问题把人看晕了。。。s#、c#、t# 代表什么,相互对应关系标明? 能简单明了的叙述你四个问题吗?这样好帮你。
追问
改好了 你看下吧~~
追答
你是要SQL语句吧。
1,查询所有同学的sno学号,sname姓名,cname选课数,score总成绩
SELECT dbo.student.sno, dbo.student.sname, dbo.Course.cname, dbo.SC.score
FROM dbo.Course INNER JOIN
dbo.SC ON dbo.Course.cno = dbo.SC.cno INNER JOIN
dbo.student ON dbo.SC.sno = dbo.student.sno
2,查询至少学过学号为“001”同学所有一门课的其它同学学号和姓名
真看不明白。
3,把SC表中“叶平”老师教的课的成绩都更改为此课程的平均成绩
4,删除学习“叶平”老师的SC表记录
从你提问中没看到teacher(tno,tname)表与其他表有任何联系的关键字段。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询