I have a simple query that uses the following command text to return values from a SQL Server to an Excel sheet. However, when the Material value is not found in the Material_Location table, it simply omits it.
How can I modify the following code to return the value of On_Hand_Qty as "0", if the Material is not found in the Material_Location table
SELECT
SO_Detail.Sales_Order,
SO_Detail.SO_Line,
SO_Detail.Material,
SO_Detail.Order_Qty,
Material_Location.On_Hand_Qty
FROM
SO_Detail
INNER JOIN Material_Location ON SO_Detail.Material = Material_Location.Material
ORDER BY
SO_Detail.Sales_Order,
SO_Detail.SO_Line
Thanks
ifnull(Material_Location.On_Hand_Qty,0)CASE,ISNULL,IIF,COALESCELeft Outer Jointo get the non matching recordleft join