SQL编程:统计n次考试的成绩
USE [new_wzjw] GO /****** Object: StoredProcedure [dbo].[成绩管理_过程化成绩录入_统计最终成绩] Script Date: 2014/4/1 19:22:01 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER proc [dbo].[成绩管理_过程化成绩录入_统计最终成绩]
USE [new_wzjw]
GO
/****** Object: StoredProcedure [dbo].[成绩管理_过程化成绩录入_统计最终成绩] Script Date: 2014/4/1 19:22:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[成绩管理_过程化成绩录入_统计最终成绩]
@kcid jxrw_code
as begin
declare c1 cursor for
select zzcj.cj,zzcj.xh from
(select xh from web_inputCj_cjb where kcId=@kcid)xsxx
left join
(select xh,round(sum(cjbl*0.01*isnull(cj,0)),0)cj from web_inputCj_xscjb xscjb left join
(select ksid,cjbl from web_inputCj_xsksb where kcId=@kcid)ksxx
on xscjb.ksid=ksxx.ksid group by xh
)zzcj on zzcj.xh=xsxx.xh
declare @cj float
declare @xh varchar(12)
open c1
fetch c1 into @cj,@xh
while @@FETCH_STATUS = 0
begin
update web_inputCj_cjb set cj=@cj where xh=@xh and kcId=@kcId
fetch c1 into @cj,@xh end
end
,上一篇: 小白直接上框架,好吗?
下一篇: Hadoop分布式集群搭建