SQLServer实验指导(第三版)习题8答案

SQLServer实验指导(第三版)习题8答案

ID:41593885

大小:54.88 KB

页数:5页

时间:2019-08-28

SQLServer实验指导(第三版)习题8答案_第1页
SQLServer实验指导(第三版)习题8答案_第2页
SQLServer实验指导(第三版)习题8答案_第3页
SQLServer实验指导(第三版)习题8答案_第4页
SQLServer实验指导(第三版)习题8答案_第5页
资源描述:

《SQLServer实验指导(第三版)习题8答案》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、usejiaoxuedbgo--pagel54实验・・1利用学生姓名查询该牛选修的课程名,成绩,以及任课教师姓名ifobject_id(1pro_l1)isnotnulldropprocedurepro_lgocreateprocedurepro_l(@snchar(8))asbeginselectcnzscoreztnfromstudentzsczcourseztczteacherwherestudent・sno=sc・snoandsc.cno=course・enoandtc.tno=teacher・tnoandcourse・cno=tc.en

2、oandsn=@snend--查询declare@snchar(8)execpro_l1张建国1一2查询某系的学生的最大年龄和最小年龄--selectdept,max(age)maxage,min(age)minagefromstudentgroupbydeptifobject_id(1pro_21)isnotnulldropprocedurepro_2gocreateprocedurepro_2(@deptchar(10),@maxagetinyintoutput,@minagetinyintoutput)asbeginselect@maxag

3、e=max(age),@minage=min(age)fromstudentwheredept=@deptend--查询declare@deptchar(10),@maxagetinyint,@minagetinyintexecpro_2「计算机J@maxageoutputz@minageoutputprint@maxageprint@minage「3利川学生姓名和课程名检索该住该课程的成绩ifobject_id(rpro_31)isnotnulldropprocedurepro_3gocreateprocedurepro_3(@snchar(8

4、),@cnchar(10),@scoretinyintoutput)asbeginselect@score=scorefromstudent,sc,coursewheresn=@snandcn=@cnend--查询declare@snchar(8),@cnchar(10)z@scoretinyintexecpro_3'弓长建国'J数据库J@scoreoutputprint@score・・4根据职称查询人数,并给出''副教授〃的人数ifobject_id(1pro_41)isnotnulldropprocedurepro_4gocreateproc

5、edurepro_4(@profchar(10),@countsmallintoutput)asbeginselect@count=count(*)fromteacherwhereprof=@profend--查询declare@profchar(10)z@countsmallintexecpro_4〔副教授J@countoutputprint@count「5统计某系某职称的人数,平均年龄,平均工资,最高工资ifobject_id(1pro_51)isnotnulldropprocedurepro_5gocreateprocedurepro_5@

6、deptchar(10),@profchar(10)z@countsmallintoutputz@avgagetinyintoutput,@avgsalsmallintoutput,@maxsalsmallintoutput)asbeginselect@coucount(*),@avgage=avg(age),@avgsal=avg(sal),@maxsal=max(sal)fromteacherwheredept=@deptandprof=@profend■■查询declare@deptchar(10),@profchar(10),@count

7、smallint,@avgagetinyint,@avgsalsmallint,@maxsalsmallintexecpro_5'计算机J「讲师>,@countoutput,@avgageoutputr@avgsaloutput,@maxsaloutputprint@countprint@avgageprint@avgsalprint@maxsal--6查询某系的教师人数,平均年龄和学生人数--selectteacher.dept,count(distincttno)t,avg(teacher.age)avgage,count(distincts

8、no)sfromteacher,studentwhereteacher・dept:=student•deptgroupbyteacher

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。