有问题再追问
数据录入模块设计
1、用SQL语句在学生表中添加本组成员信息。(本组成员信息是什么?)
--按这种格式插入就行,这里举例说明
insert into student
select '00001','张三','男', cast('2013-12-28' as datetime),'01','xxx@qq.com'
union all
select '00001','李四','男', cast('2013-12-28' as datetime),'01','xxx@qq.com'
2、用SQL语句在课程表中添加数据:
C语言(代码001)、英语(代码002)ACCESS(代码003)、数据库(代
码004)
insert into course
select '001','C语言'
union all
select '002','英语'
union all
select '003','ACCESS'
union all
select '004','数据库';
3、用SQL语句在成绩表中添加本组成员的考试成绩数据: C语言、英语、ACCESS。
--根据student表的人员进行插入,这里举例说明
insert into socre
select '00001','001',90
union all
select '00001','002',80
union all
select '00001','003',85
union all
select '00001','004',92
union all
select '00002','001',80
union all
select '00002','002',85
union all
select '00002','003',88
union all
select '00002','004',78
数据查询模块设计
1、用SQL语句查询并输出显示本组男性同学的学号、姓名、性别、出生日期和邮箱。
select sid,sname,sex,birthday,email
from student where sex='男' and xzbh=本组编号
2、用SQL语句查询并输出显示本组成员的全部信息。
select * from student where xzbh=本组编号
3、用SQL语句查询并输出显示成员的各科成绩,按高低排序。
select t1.sid,t1.sname,t3.kcmc,t2.score
from student t1,score t2,course t3
where t1.sid=t2.sid and t3.cno=t2.cno
order by t2.score asc
4、用SQL语句查询并输出显示:
(1)本组英语课程考试不及格、60~80分、80~100分同学的名单、人数。
select t1.sid,t1.sname
from student t1,score t2,course t3
where t1.sid=t2.sid and t3.cno=t2.cno
and t3.kcmc='英语' and t2.score<60
select t1.sid,t1.sname
from student t1,score t2,course t3
where t1.sid=t2.sid and t3.cno=t2.cno
and t3.kcmc='英语'
and t2.score>60 and t2.score<80
select t1.sid,t1.sname
from student t1,score t2,course t3
where t1.sid=t2.sid and t3.cno=t2.cno
and t3.kcmc='英语'
and t2.score>=80 and t2.score<=100
select t3.kcmc,
sum(case when t2.score<60 then 1 else 0 end) 不及格人数,
sum(case when t2.score>=60 and t2.score<80 then 1 else 0 end) 60到80人数,
sum(case when t2.score>=80 and t2.score<=100 then 1 else 0 end) 80到100人数
from student t1,score t2,course t3
where t1.sid=t2.sid and t3.cno=t2.cno and t3.kcmc='英语'
(2)本组英语考试成绩的平均分、最高分、最低分。
select t3.kcmc,avg(t2.score),max(t2.score),min(t2.score)
from student t1,score t2,course t3
where t1.sid=t2.sid and t3.cno=t2.cno and t3.kcmc='英语' and xzbh=本组编号
(3)本组ACCESS考试成绩最高分、最低分的同学名单。
select t.sid,t.sname,t.score
from(
select t1.sid,t1.sname,t3.score
row_number()over(order by max(t2.score) desc)maxrn,
row_number()over(order by min(t2.sorce) asc)minrn
from student t1,score t2,course t3
where t1.sid=t2.sid and t3.cno=t2.cno and t3.kcmc='ACCESS' and xzbh=本组编号)t
where maxrn=1 or minrn=1
(4)将本组各科最低分同学的成绩加10分。
update score t1 set score=(select min(score)+10 from score t2 where t1.cno=t2.cno)