南邮大数据库实验报告材料
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
课实验报告
课程名:数据库原理与应用任课教师:程录庆
专业:信息管理与信息系统学号:B13111513
姓名:解一涵
二○一四至二○一五年度第二学期
邮电大学管理学院
(2)课程表
(3)成绩表
(4)教师表
2、查询结果及SQL语言(1)找出男性学生的SELECT NAME
FROM S
WHERE XB="男";
(2)找出不是“2031”班的学生
SELECT *
FROM S
WHERE SNO NOT IN
(SELECT SNO
FROM S
WHERE CLASSNO='B131115');
(3)查询“峰”老师所教课程的课程名称和学分SELECT CNAME, XF
FROM T, C
WHERE NAME="峰" And T.TNO=C.TNO;
(4)检索出选修了课程代号为“c11”和“c23”课程的学生
SELECT SNO
FROM G
WHERE CNO In ("1","2");
(5)查询至少选修了一门“峰”老师的课程的学生
SELECT , S.SNO
FROM (S INNER JOIN G ON S.SNO=G.SNO) INNER JOIN C ON O=O WHERE O="6" Or O="7"
GROUP BY , S.SNO;
(6)求选修了课程名为“数据库原理”的所有学生的学号和
SELECT S.SNO,
FROM S INNER JOIN G ON S.SNO=G.SNO
WHERE (((O)="1"));
(7)找出学生代号为“S101”和“S102”两个学生都选修了的课程
SELECT S.SNO, O, AME
FROM (S INNER JOIN G ON S.SNO=G.SNO) INNER JOIN C ON O=O
WHERE S.SNO LIKE'B13111502' AND Exists (SELECT* FROM G AS G2 WHERE O=O AND G2.SNO LIKE'B13111510')<>False;
(8)检索出没有被任何学生选修的课程
SELECT *
FROM C
WHERE O NOT IN (SELECT O FROM G);
(9)求出每个学生的成绩的平均分和总分
SELECT S.SNO, Avg(G.GRADE) AS 平均分, Sum(G.GRADE) AS 总分FROM S INNER JOIN G ON S.SNO=G.SNO
GROUP BY S.SNO;
(10)求至少三门以上课程成绩在90分以上的学生学号SELECT , S.SNO, Count(G.GRADE) AS GRADE之计数FROM S INNER JOIN G ON S.SNO=G.SNO
WHERE (((G.GRADE)>90))
GROUP BY , S.SNO
HA VING (((COUNT(G.GRADE))>2));
(11)求获得学分数在200以上的学生
SELECT S.SNO, , Sum(G.GRADE) AS GREA T之总计FROM S INNER JOIN G ON S.SNO=G.SNO
GROUP BY S.SNO,
HA VING Sum(G.GRADE)>200;
(12)求出少于10个学生选修的课程
SELECT AME, O, Count(G.GRADE) AS GRADE之计数
FROM (S INNER JOIN G ON S.SNO=G.SNO) INNER JOIN C ON O=O GROUP BY AME, O
HA VING (((Count(G.GRADE))<10));
(13)求出有四门课程考试不及格的学生的
SELECT , Count(G.GRADE) AS GRADE之计数
FROM S INNER JOIN G ON S.SNO=G.SNO
WHERE (((G.GRADE)<60))
GROUP BY
HA VING (((Count(G.GRADE))=4));
(14)求出每个老师所教课程的学分总数
SELECT C.TNO, , Sum(C.XF) AS XF之总计FROM C INNER JOIN T ON C.TNO=T.TNO
GROUP BY C.TNO, ;
(15)求出教了三门课以上的老师
SELECT , T.TNO, Count(O) AS CNO之计数FROM T INNER JOIN C ON T.TNO = C.TNO
GROUP BY , T.TNO
HA VING (((Count(O))>=3));
(16)求出只教一门课程的老师
SELECT , T.TNO, Count(O) AS CNO之计数FROM T INNER JOIN C ON T.TNO=C.TNO
GROUP BY , T.TNO
HA VING (((Count(O))=1));
(17)求出每一个班级中每一门课程获得最高分的学生的学号SELECT S.CLASSNO, O, Max(G.GRADE) AS 最高分FROM S INNER JOIN G ON S.SNO=G.SNO
GROUP BY S.CLASSNO, O;