SQL 存储过程示例讲解

create proc score_result
@courseName varchar(20)       --参数
as                            
declare               --定义变量
@courseNo int,         @testTime1 datetime, @avg int begin               --方法开始 select @courseNo=courseNo from course where courseName=@courseName select @testTime1=max(testTime) from chengji where courseNo=@courseNo; select @avg=AVG(result) from chengji where courseNo=@courseNo and testtime=@testTime1 select @avg --打印平均分 select * from student where studentno in (select studentNo from chengji where courseNo=@courseNo and testTime=@testTime1 and result<60);--打印不及格的学生信息 end;     --方法结束

 

posted @ 2018-03-18 12:01  ggsmdaa  阅读(177)  评论(0编辑  收藏  举报