![]() 这个SQL如果出现求和的sum(a.SaleArea)出现0的话,会直接报错 这个SQL该怎么处理,实现出现0的时候显示空或者其他的东西 SELECT sum(b.Amount)*10000/sum(a.SaleArea) as TargetCost FROM (SELECT ProductID,sum(SaleArea) as SaleArea from dbo.Product_Sale group by ProductID) a left join (select PeriodID,ProductID,Amount,CostCode,MAX(SaveDate) as SaveDate FROM dbo.Product_Cost group by PeriodID,ProductID,Amount,CostCode) b on a.ProductID = b.ProductID left join dbo.Relation_Period c on b.PeriodID = c.C_PeriodID left join dbo.DIM_Period d on c.PeriodID = d.PeriodID where b.CostCode = 'A.09' and a.ProductID IN ('${ProductID}') |
最佳回答 |
||||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|