上海应用技术学院-数据库-实验五.docVIP

  • 8
  • 0
  • 约1.47千字
  • 约 4页
  • 2021-12-02 发布于广东
  • 举报
上海应用技术学院-数据库-实验五 上海应用技术学院-数据库-实验五 PAGE 上海应用技术学院-数据库-实验五 《数据库原理及应用》课程实验报告 实验名称 综合查询 实验序号 5 实验日期 姓 名 院系 计算机科学与信息工程学院 班 级 13 学 号 13 专 业 计算机科学与技术 指导教师 刘梅 成 绩 一、实验目的和要求 1. 掌握SELECT语句在多表查询中的应用 2. 掌握SELECT语句在复杂和综合查询中的应用 二、实验预习内容 1. 2. 3. 三、实验项目摘要 1.对“教学管理”数据库,完成以下查询要求 (1)统计有学生选修的课程门数。 (2)求选修4号课程的学生的平均年龄。 (3)求学分为3的每门课程的学生平均成绩。 (4)统计每门课程的学生选修人数,超过3人的课程才统计。要求输出课程号和选修人数,查询结果按人数降序排列,若人数相同,按课程号升序排列。 (5)求年龄大于女同学平均年龄的男学生姓名和年龄。 (6)求年龄大于所有女同学年龄的男学生姓名和年龄。 2.对“供应关系”数据库,完成以下查询要求 (1)查询上海的供应商提供给上海的任一工程的零件的代号; (2)查询上海供应商不提供任何零件的工程代号; (3)查询由供应商S1提供零件的工程代号; (4)查询所有这样的二元组city,city,使得第一个城市的供应商为第二个城市的工程提供零件; (5)查询使用了最轻的零件的工程代号; 四、实验结果与分析 1.(1)select count(distinct cno) from sc (2)select avg(age) from s,sc where = and cno=4 (3)select avg(score) from c,sc where = and ct=3 (4) select distinct cno,count(cno)选修人数 from sc group by cno having count(cno)3 order by count(cno) desc,cno (5)select sn,age from s where sex=男 and age(select avg(age)from s where sex=女) (6)select sn,age from s where sex=男 and ageall(select age from s where sex=女) 2.(1)select from spj where in (select jn from j where =上海) and in(select sn from s where =上海) (2) select distinct jn from spj where jn not in(select from s,spj where = and =上海) (3)select distinct jn from spj where sn=s1 (4)select distinct , from s,p,j,spj where = and = (5)select distinct jn from spj where in (select pn from p where weight= (select min(distinct weight) from p)) 3. 注:空间不够,可以增加页码。

文档评论(0)

1亿VIP精品文档

相关文档