pu mode line station testtotal testpass FPY
PU1 FA_PQC I FAT DD 20060821 6433 6361 .9888
PU1 FA_PQC I FFT DD 20060821 6413 6368 .9930
PU1 FA_PQC I FRT DD 20060821 6415 6384 .9952数据在同一个表中,现在我要实现0.9888*0.9930*0.9952
group by pu1,FA_PQC,I 结果应该是
pu1 FA_PQC I 0.9888*0.9930*0.9952
高手快帮忙啊
PU1 FA_PQC I FAT DD 20060821 6433 6361 .9888
PU1 FA_PQC I FFT DD 20060821 6413 6368 .9930
PU1 FA_PQC I FRT DD 20060821 6415 6384 .9952数据在同一个表中,现在我要实现0.9888*0.9930*0.9952
group by pu1,FA_PQC,I 结果应该是
pu1 FA_PQC I 0.9888*0.9930*0.9952
高手快帮忙啊
returns numeric(10,4)
as
begin
declare @ret numeric(10,4)
select @ret=isnull(@ret,1)*FPY from TName where pu=@pu and mode=@mode and line=@line
return @ret
end
goselect pu,mode,line,dbo.f_multiply(pu,mode,line) from TName group by pu,mode,line
go
--建立函数
create function fn_Cal(
@pu varchar(20),
@mode varchar(20),
@line varchar(10)
)
returns numeric(18,10)
as
begin
declare @r numeric(18,10)
set @r=1
select @r=@r*FPY from tablename
where pu=@pu and
mode=@mode and
line=@line
return @r
endgo--调用一
select dbo.fn_Cal('pu1','FA_PQC','I')--调用二
select pu,mode,line,dbo.fn_Cal(pu,mode,line) as cal
from tablename
group by pu,mode,line