sql计算问题
写了一个存储过程,其中包含除法计算,但是有一个除数为0,这是因为数据录入的时候有问题是否会造成我查出的数据不显示
代码中Fweight 为0
set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER proc [dbo].[Pd_TB_Profit_CP](@FDateB datetime,@ssql varchar(8000))asset nocount on SET ANSI_WARNINGS OFFselect t1.FItemName,sum(t1.FQty) FQty,sum(t1.FDAmount) FDAmount,sum(isnull(t1.Fcost,0)) Fcost,sum(isnull(t2.FDDHLFee,0)*(isnull(t1.FDWeight/t2.FWeight,0))) FDDHLFee,sum(isnull(t2.FDHLFee*(t1.FDWeight/t2.FWeight),0)) FDHLFee,sum(isnull(t1.FDAmount,0)+(isnull(t2.FDDHLFee,0)*(t1.FDWeight/t2.FWeight))-(isnull(t1.Fcost,0)+(isnull(t2.FDHLFee,0)*(t1.FDWeight/t2.FWeight)))) FZprofit,sum(isnull(t1.FDAmount,0)+(isnull(t2.FDDHLFee,0)*(t1.FDWeight/t2.FWeight))-(isnull(t1.Fcost,0)+(isnull(t2.FDHLFee,0)*(t1.FDWeight/t2.FWeight))))/count(distinct t1.fid) FDprofitfrom SU_Sale_TBStockBillEntry t1 inner join SU_Sale_TBStockBill t2 on t1.fid=t2.fid where CONVERT(varchar(6),[FDate],112)=@FdateB GROUP BY t1.FItemNameunion allselect '合计', sum(t1.FQty),sum(t1.FDAmount),sum(t1.Fcost),sum(isnull(t2.FDDHLFee,0)*(isnull(t1.FDWeight/t2.FWeight,0))),sum(isnull(t2.FDHLFee*(t1.FDWeight/t2.FWeight),0)),sum(isnull(t1.FDAmount,0)+(isnull(t2.FDDHLFee,0)*(t1.FDWeight/t2.FWeight))-(isnull(t1.Fcost,0)+(isnull(t2.FDHLFee,0)*(t1.FDWeight/t2.FWeight)))),sum(isnull(t1.FDAmount,0)+(isnull(t2.FDDHLFee,0)*(t1.FDWeight/t2.FWeight))-(isnull(t1.Fcost,0)+(isnull(t2.FDHLFee,0)*(t1.FDWeight/t2.FWeight))))/count(distinct t1.fid)from SU_Sale_TBStockBillEntry t1 inner join SU_Sale_TBStockBill t2 on t1.fid=t2.fid where CONVERT(varchar(6),[FDate],112)=@FdateB