S2 1-9练习

来源:互联网 发布:昆山启航cnc编程培训 编辑:程序博客网 时间:2024/05/16 08:22
--统计并显示2013-08-09 的oop考试平均分--如果平均分在70分以上,显示“考试成绩优秀”,并显示前三名学生的考试信息--如果在以下,显示“考试成绩较差”,并显示后三名学生的考试信息  select * from result order by examdate  --00.求出oop课程对应的课程编号 declare @subid int  select @subid=SubjectId from Subject where subjectname='oop'   --01.查询平均分 declare @avg int  select @avg=avg(Studentresult) from result where examdate>='2013-08-09' and examdate <'2013-08-10' and subjectid=@subid  if(@avg>=70) begin   print '成绩优秀'   --打印前三名的成绩   select  top 3 * from result    where  examdate>='2013-08-09' and examdate <'2013-08-10' and subjectid=@subid   order by studentresult desc    end --        declare @sum int        set @sum=0    declare @num int    set @num=1      while(@num<=100)begin  if(@num%2=0)  begin set @sum=@num+@sum  endset  @num=@num+1  end  print @sum        

0 0
原创粉丝点击