这几天学的新东西,都在下边的代码里体现出来了
刚写出来的时候,写了个死循环
如下:
declare @n int,@bi int,@ji int,@maxw int,@maxl int
select @bi=avg(writtenexam),@ji=avg(labexam) from stumarks
select @maxl=max(labexam) from stumarks
select @maxw=max(writtenexam) from stumarks
if (@bi>@ji)
begin
print'本班机试成绩较低,提分后的成绩为:'
while (1=1)
begin
select @n=count(*) from stumarks where labexam<60
if(@n >0 and @maxl<97)
update stumarks set labexam=labexam+1
else
break
end
end
else
begin
print'本班笔试成绩较低,提分后的成绩为:'
while (1=1)
begin
select @n=count(*) from stumarks where writtenexam<60
if(@n >0 and @maxw<97)
update stumarks set writtenexam=writtenexam+1
else
break
end
end
select * from stumarks
可以看的出来,这个数据不会随着循环而更新,所以是个死循环哩
后来在LG帮助下,找到了错误,改正了过来
数据库和源代码下载:
https://files.cnblogs.com/sophia0405/Data.rar
如下:
declare @n int,@bi int,@ji int,@maxw int,@maxl int
select @bi=avg(writtenexam),@ji=avg(labexam) from stumarks
select @maxl=max(labexam) from stumarks
select @maxw=max(writtenexam) from stumarks
if (@bi>@ji)
begin
print'本班机试成绩较低,提分后的成绩为:'
while (1=1)
begin
select @n=count(*) from stumarks where labexam<60
if(@n >0 and @maxl<97)
update stumarks set labexam=labexam+1
else
break
end
end
else
begin
print'本班笔试成绩较低,提分后的成绩为:'
while (1=1)
begin
select @n=count(*) from stumarks where writtenexam<60
if(@n >0 and @maxw<97)
update stumarks set writtenexam=writtenexam+1
else
break
end
end
select * from stumarks
可以看的出来,这个数据不会随着循环而更新,所以是个死循环哩
后来在LG帮助下,找到了错误,改正了过来
数据库和源代码下载:
https://files.cnblogs.com/sophia0405/Data.rar