SQL实验五答案_第1页
SQL实验五答案_第2页
SQL实验五答案_第3页
全文预览已结束

下载本文档

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

文档简介

1、精选文档1. (1) declare a int,b int declare c float declare s1 char(3),s2 char(3)set a=5set b=4set c=4.0set s1='abc'set s2='def'select a*b as'a与b的积', a/b as'a与b的商', a%b as'a与b的余数', a&b as '按位与', a|b as '按位或', ab as '按位异或', a/c as'a与c

2、的商', s1+s2 as's1与s2的连串'(2)select version(3)use stuinfodeclare x char(8)select x=sname from studentwhere sno='105'select x(4)use stuinfodeclare y int,z intselect y=COUNT(*),z=max(degree)from scorewhere cno='3-105'select y as'选课人数',z as'最高成果'2.(1)use stuinfo

3、select sname'姓名',cno '课程名',casewhen degree>=90 then'优'when degree>=80 then'良'when degree>=70 then'中'when degree>=60 then'及格'when degree<60 then'不及格'end as '成果等级'from score,studentwhere score.sno=student.snoorder by cno as

4、c,sname asc(2)use stuinfodeclare a float,b float,c floatset a=(select AVG(degree)from score where sno in(select sno from student where ssex='男')set b=(select AVG(degree)from score where sno in (select sno from student where ssex='女')set c=a/bif c>1.3print '男生比女生成果高多了'if c&

5、lt;=1.3 and c>=0.8print '男生与女生成果差不多'if c<0.8print '女生比男生成果高多了'(3)use stuinfocreate table xsrq (spno char(4) default('3741'), spname char(20) default('苹果MacBook Pro '), scrq date, sl int)use stuinfodeclare m intset m=0while m<20 begin set m=m+1 insert into xsr

6、q(scrq) values (dateadd(DAY,m,getdate() end3. (1)use stuinfogocreate function average(cn char(4)returns floatasbegindeclare aver floatselect aver=(select avg(degree)from score where cno=cn)return averendgodeclare coursel char(6)set coursel='3-105'select dbo.average(coursel) as '3-105号课程的平均成果'go(2)use stuinfogocreate function cj(no char(5)returns tableasreturn (select sname,cno,degree from student,scorewhere student.sno=no and student.sno=score.

温馨提示

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

评论

0/150

提交评论