mssql 函数问题 where 后面可以接几个变量条件
create function fninoutgetmoney
(@com char(4)
,@department char(4)
,@contractflag int
,@convert varchar(50)
)
returns numeric(24,5)
as
begin
declare @company char(4)
declare @dep char(4)
declare @con varchar(50)
declare @flag int
declare @result numeric(24,5)
set @company=@com
set @dep =@department
set @con=@convert
set @flag=@contractflag
set @result=
(select sum(e_amount) amount from storagedetail
where
i_flag=@contractflag and v_contract_serial=@convert and c_comany_type=@company and c_department_type=@depgroup by i_flag,v_contract_serial,c_comany_type,c_department_type)
return @result
end
------解决方案--------------------更正下
create function fninoutgetmoney
(@com char(4) ,@department char(4) ,@contractflag int,@convert varchar(50) )
returns numeric(24,5)
as
begin
declare @result numeric(24,5)
set @result=
(select sum(e_amount) amount from storagedetail where i_flag=@contractflag and v_contract_serial=@convert and c_comany_type=@com and c_department_type=@department group by i_flag,v_contract_serial,c_comany_type,c_department_type)
return @result
end