--简单联接查询 lect s.SNO 学生编号,s.DEGREE 成绩 from SCORE s,TEACHER t,COURSE c where s.CNO=c.CNO and c.TNO=t.TNO and t.TNAME='张旭' --子查询 lect sno 学生编号, degree 成绩 from score where cno = (lect cno from cour where tno= (lect tno from teacher where tname='张旭')) |
lect * from student where sno in (lect distinct sno from score where cno ='3-105'and degree> (lect degree from score where sno='109' and cno ='3-105')) |
lect tname 教师名 from teacher where tno in (lect tno from cour where cno in (lect cno from score group by cno having count(cno)>5)) |
lect st.sname 姓名,c.cname 选课名,sc.degree 成绩 from score 游湖sc,student st,cour c 天猫双十一预售where c.CNO=sc.CNO and sc.切实落实SNO=st.SNO and st.sx='男' and c.cname='计算机导论' |
go declare @cname varchar(20) ='计算机导论' --变量名可以不按要求来 declare @avg float declare @cno varchar(20) lect @cno=cno from cour where cname=@cname lect @avg =avg(degree) from score where cno=@cno if(@avg>80) begin print '成绩优秀' --如果没有这句话扣2分 lect top 3 st.sname 姓名,sc.degree 成绩 from student st ,score sc where st.sno=sc.sno and sco=@cno order by degree desc end el begin print '成绩较差' --如果没有这句话扣2分 lect top 3 st.sname 姓名,sc.degree 成绩 from student st ,score sc where st.sno=sc.sno and sco=@cno order by degree asc end |
declare @courName varchar(50) ='操作系统' --选修课名 declare @courID varchar(20) --选修课编号 declare @avgDegree float --平均分 declare @maxDegree float 神笔马良故事简介--最高分 lect @courID=cno from COURSE where CNAME=@courName lect @avgDegree= AVG(DEGREE) from SCORE where CNO=@courID while(1=1) begin if(@avgDegree<80) begin update SCORE t DEGREE=DEGREE+2 where CNO=@courID lect @avgDegree= AVG(DEGREE) from SCORE where CNO=@courID continue end el break end -- 第二种 while写法开始 while(@avgDegree <80) begin update score t degree=degree+2 where cno=@courID lect @avgDegree =avg(degree) from score where cno=@courID end --第二种while写法结束 lect @maxDegree=max(DEGREE) from SCORE where CNO=@courID print '经过调分后选修'+@courName+'的学生最高分为:'+convert(varchar(20),@maxDegree)+ '分' --或cast(@maxDegree as varchar(20)) go |
lect sno 学号, DEGREE 成绩,成绩等级= ca when DEGREE >90 then '优' when DEGREE between 80 and 90 then '良' when DEGREE between 70 and 79 then '中' when DEGREE between 60 and 69 then '差' --when DEGREE <60 then '不及格' el '不及格' end from SCORE go |
--判断是否存在此视图 4分 if(exists(lect * from sysobjects where name='V_newScore')) drop view V_newScore go create view V_newScore as lect st.sname,c.cname,sc.degree,t.tname from student st,score sc,cour c,teacher t where世界多极化 st.sno=sc.sno and sc.cno=c.cno and c.tno =t.tno and sc.degree>=60 go |
begin transaction --开启事务 declare @lsno varchar(20) --声明变量 declare @ksno varchar(20) declare @ldegree float declare @kdegree float --赋值变量 lect @lsno =sno from student where sname='陆君' lect @ksno =sno from student where sname='匡明' lect @ldegree=degree from score where sno=@lsno and cno='3-105' lect @kdegree=degree from score where sno=@ksno and cno='3-105' declare @errorCount int =0 update score t degree =@ldegree where sno=@ksno and cno='3-105' t @errorCount =@errorCount +@@error update score t degree =@kdegree where sno=@lsno and cno='3-105' t @errorCount =@errorCount +@@error if(@errorCount <> 0) begin print '发生异常,回滚' rollback transaction end el议论文常用素材 begin print '没有异常,提交' commit transaction end go |
--判断是否存在此存储过程 4分 if(exists(lect * from sysobjects where name='proc_sname_info')) drop proc proc_sname_info go create proc proc_sname_info @sname varchar(20) as if(exists(lect * from student where sname=@sname)) begin if(exists(lect * from score where sno= (lect sno from 小学家访记录大全100篇student where sname=@sname))) begin lect sc.sno,c.cname,sc.degree,t.tname from student st,score sc,cour c,teacher t where st.sno=sc.sno and sc.cno=c.cno and c.tno=t.tno and st.sname=@sname end el print @sname+'学生没有参加考试' end el print @sname+'学生不存在' go exec proc_sname_info '王芳' |
执业药师历年真题SQL语句题 | 6分/题 共24分 | 不限制答题语句方式答对得分答错不得分 |
T-SQL编程题 | 10分/题 共30分 | |
创建视图 | 12分/题 | |
创建事物 | 14分/题 | |
存储过程 | 20分/题 | |
本文发布于:2023-06-08 09:02:18,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/fan/89/1021832.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |