实验五实验报告(共10篇).doc
文本预览下载声明
实验五实验报告(共10篇)
数据库实验5实验报告
《数据库原理与设计》实验报告
报告创建时间:
篇二:实验五 实验报告
云南大学软件学院
实 验 报 告
课程: 数据库原理与实用技术实验 任课教师: 包崇明 姓名: 李子厚学号: 20121120009专业: 软件工程 成绩:
实验5 数据查询
1、完成教科书163页的如下习题:
[3.2]b: select aid from AGENTS where percent=all(select percent from
AGENTS)
[3.5]: select aid,cid from AGENTS A,CUSTOMERS C where aid not in(select aid from ORDERS X where X.cid=C.cid and X.aid=a.aid)
[3.8]a: select cid,pid,MAX(dollars) as MAXSPENT from ORDERS group by cid, pid, dollars
[3.8]b:select AVG (MAXSPENT) as AVERAGE from (select cid,pid,MAX(dollars) as MAXSPENT from ORDERS group by cid,pid,dollars) as x group by cid
[3.11]b: (select cid,pid,AVG(dollars) as AVGSPENT from ORDERS group by cid,pid,dollars) as x where cid not in ( select cid from ( select cid,pid,AVG(dollars) as AVGSPENT from ORDERS group by cid,pid,dollars) as x where AVGSPENT 300)
[3.11]f: select pid from ORDERS where cid in ( select cid from CUSTOMERS where city=#39;Dallas#39;)
[3.11]j: update PRODUCTS set price=1.1*price where city=#39;Duluth#39;or city=#39;Dallas#39;
[3.11]l select aid,[percent] from AGENTS a where not exists( select cid from CUSTOMERS c where city=#39;Duluth#39; and not exists( select o.cid from ORDERS o where o.cid=c.cid and a.aid=o.aid)) order by percent
2、在“学生管理数据库”中完成如下查询:
(1)列出软件2班女同学的名单 select
*
from
学生表 where 班级=#39;软件班#39; and 性别=#39;女#39;;
(2)列出2002年元旦前注册的学生名单
select * from 学生表 where 入学日期#39;2002-1-1#39;;
(3)列出所有年龄在19岁以下,或者女同学的名单
select * from 学生表 where 年龄=#39;19#39; or 性别=#39;女#39;;
(4)列出没有先修课的课程名select * from 课程表 where 先修课 is null ;
(5)列出既不是“电子系”
,也不是“会计系”的学生的学号、姓名和所在院系
select
学号,姓名,所在院系 from 学生表 where 所在院系 not in(#39;电子系#39;,#39;会计系#39;);
(6)查询选修“C801”课程的学生的最高分
select max (成绩)as c801的最高分 from 成绩表 where 课程号=#39;c801#39;;
(7)统计男、女学生各自的人数和平均年龄
select 性别 ,count (性别) as 人数,avg (年龄) as 平均年龄 from 学生表 group by 性别;
(8)列出选修了一门以上课程的学生学号,及其选修门数
select 学号,count(学号) as 选修门数 from 成绩表 group by 学号 having count(学号)1;
(9)查询“沈香娜”同学所在班级的所有学生的学号和姓名
select 学号,姓名 from 学生表
显示全部