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; --方法结束