1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
declare @stg int,@moy float,@s float,@Coef int,@SomCoef int,@NoteM float,@NCoef float
declare curstg cursor for select idStg from Stagiaire
open curstg
fetch next from curstg into @stg
while @@FETCH_STATUS=0
begin
set @somCoef=0
set @Coef=0
declare curMat cursor for select Coef,Note.Note from matiere
where idMat in (select idMat from Note where @stg=Note.idStg)
fetch next from curMat into @Coef,@NoteM
while @@FETCH_STATUS=0
begin
set @somCoef=@somCoef+@Coef
set @NCoef=@NCoef*@Coef
set @s=@s+@NCoef
fetch next from curMat into @Coef,@NoteM
end
close curMat
set @moy=@s/@somCoef
print 'Moy du Stg Num '+convert(varchar(5),@stg)+' est '+convert(varchar(5),@moy)
fetch next from curstg into @stg
end
close curstg |
Partager