|
|
Question : converting null to zero
|
|
Hi,
The following sql statement works fine. How can I modify the stateent to retrive 'Sum_Order_Qty' to 0 if it is null?
SELECT ol.PartNo, Model,CatName, p.PartName, Sum_Order_Qty, Sum_Stock, Sh_Qty,WH_Qty,RB_Qty, Sum_Req_Qty, Avail_Qty = Sum_Stock + Sum_Order_Qty - Sum_Req_Qty FROM (SELECT PartNo, Sum(OQty) as Sum_Order_Qty FROM tblOrderDet GROUP BY PartNo) ol LEFT JOIN tblSpareParts p ON p.PartNo = ol.PartNo LEFT JOIN (SELECT PartNo, Sum(Qty) as Sum_Req_Qty FROM tblShortPartsList GROUP BY PartNo) sl ON sl.PartNo = ol.PartNo JOIN (SELECT PartNo, Sum(OnHand) as Sum_Stock FROM tblStock GROUP BY PartNo) s ON s.PartNo = ol.PartNo LEFT JOIN (Select PartNo,OnHand as Sh_Qty from tblStock where storeid='SH') a ON ol.partno=a.partno LEFT JOIN (Select PartNo,OnHand as WH_Qty from tblStock where storeid='WH') b ON ol.partno=b.partno LEFT JOIN (Select PartNo,OnHand as RB_Qty from tblStock where storeid='RB') c ON ol.partno=c.partno LEFT JOIN Models m ON p.MCode=m.MCode LEFT JOIN Categories ca ON p.CatCode=ca.CatCode
please help me with the sql statment?
ayha
|
Answer : converting null to zero
|
|
specifically...
FROM (SELECT PartNo, ISNULL(Sum(OQty), 0) as Sum_Order_Qty FROM tblOrderDet GROUP BY PartNo) ol
|
|
|
|
|