après avoir créé ma fonction puis la teste, elle m'affiche null dans le cas ou il y une valeur égale à 0

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
create FUNCTION dbo.fnmoyanparmat
(@moy1 as float , @moy2 as float)
returns float
 begin
declare @result float
if @moy1>0 and @moy2>0 
set @result=(@moy1*1+@moy2*2)/3
return @result
if @moy1=0  and @moy2>0
set @moy1=0
set @result=@moy2
return @result
if @moy1>0 and @moy2=0 
set @moy2=0
set @result=@moy1
return @result
end;
 
GO
select dbo.fnmoyanparmat((12),0)