Using Command Sum

Printed From: Crystal Reports Book — Forum Name: Technical Questions

I'm trying to create a report to display status of work orders. I'm utilizing multiple tables to accomplish this. The INNER JOIN has been most useful for sure! Now where I'm hitting a road block in material inventory. Having the same material designation with multiple heat lots created issues for this report. The sum of the material proved to be difficult in crystal 2011. So I found the SUM command (SQL). This works a real treat actually:

Sum(Material_Location.On_Hand_Qty) AS Inv

My issue though is when I have no material (NULL) the row doesn't display at all. I've tried countless ideas via the web but just can't get the blank null values to display!?

This last Command line works great if there is inventory of material:

SELECT Sum(Material_Location.On_Hand_Qty) AS Inv
FROM Material_Req INNER JOIN Material_Location ON Material_Req.Material=Material_Location.Material
GROUP BY Material_Req.Material

Is this a bigger issue than I realize trying to integrate Command and Table Data?




You could put in a case statement into your SQL query.

SELECT
CASE WHEN Sum(Material_Location.On_Hand_Qty) IS NULL THEN 0 ELSE Sum(Material_Location.On_Hand_Qty) END AS Inv
FROM Material_Req INNER JOIN Material_Location ON Material_Req.Material=Material_Location.Material
GROUP BY Material_Req.Material