数据库考试重点.doc_第1页
数据库考试重点.doc_第2页
数据库考试重点.doc_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

use 教学库GO-1select * from 学生 where 年龄=(select max(年龄) from 学生 where 性别=女)GO-3-第一种做法select s.姓名,s.专业 from 学生 s inner join 选课 sc on s.学号=sc.学号inner join 课程 c on sc.课程号=c.课程号 and c.课程名=c+程序设计-第二种做法select s.姓名,s.专业 from 学生 s,课程 c,选课 sc where s.学号=sc.学号 and sc.课程号=c.课程号 and c.课程名=c+程序设计GO-4select 课程号, count(学号) as 选课人数 from 选课 group by 课程号GO-5select 姓名,性别,年龄,专业 from 学生 where 专业 in (计算机网络,通信,电子)order by 性别 DESC,专业 ASC九章课后题use 教学库go-9_1_1select count(distinct 课程号) as 有选课门数 from 选课go-9_1_2select avg(年龄) as 选101课平均年龄 from 学生 where 学号 in(select 学号 from 选课 where 课程号=0300101)go-9_1_3select 课程号,avg(成绩) as 平均成绩 from 选课group by 课程号 having 课程号 in(select 课程号 from 课程 where 学分=3)go-9_1_4select 课程号,count(*) as 选修人数 from 选课group by 课程号 having count(*)3order by 选修人数 desc,课程号go-9_1_5select 姓名 from 学生 where 学号(select 学号 from 学生 where 姓名=王三朋) and 年龄(select avg(年龄) from 学生 where 性别=女) go-9_1_9select 姓名,年龄 from 学生 where 性别=男 and 年龄(select max(年龄) from 学生 where 性别=女) go-9_1_10select 姓名,年龄,性别 from 学生 where 年龄(select 年龄 from 学生 where 姓名=王三朋)go-9_1_11select top 1 学号 from 选课 where 课程号=0300105order by 课程号,成绩 descgo-9_1_12select a.姓名,b.课程号,b.成绩 from 学生 a inner join 选课 b on a.学号=b.学号go-9_1_13select sum(成绩) as 总成绩 from 选课 where 成绩=60 group by 课程号 having count(学号)=4order by 总成绩 descGO-9-2use 教学库goif exists(select * from 选课 where 学号=20090311002)select 课程号,成绩 from 选课 where 学号=20090311002elseprint 此学生无成绩!GO-9-3create function cunstu(zy char(50),cn char(11) returns intas begindeclare cun intselect cun=(select count(*) from 选课,学生where 选课.学号=学生.学号 and 课程号=cn and 专业=zy) return cun end goselect dbo.cunstu(0300101,计算机网络) as 0300101课计算机网络专业的选课人数goGO-9-4create function kc_cj(zy char(50) returns tableas return(select 课程号,avg(成绩) as 平均成绩 from 选课 inner join 学生 on 选课.学号=学生.学号 and 专业=zy group by 课程号)goselect * from dbo.kc_cj(计算机网络) GO-9-5use 仓库库存gos

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论