I have two tables, one is MblEquip and the other is MobileDowntime. The query(below) results only show the Mobile Equipment that had downtime this month it doesn’t show all the equipment. I am wanting to put zero’s for the equipment that doesn’t have any Downtime this month. Any Ideas how to show the other equipment and put zero’s in those rows that are null.
SELECT a.EquipNbr, case when Sum(a.Downtime) is null then 0 else Sum(a.Downtime)end Downtime FROM MobileDowntime (nolock) a
join MblEquip (nolock) b on a.EquipNbr = b.EquipNbr
Where b.DelFlg = 0 and b.EquipNbr != 'Clean Shop' and a.DateTm Between DATEADD(month, DATEDIFF(month, 0, getDate()), 0) and DATEADD(month, DATEDIFF(month, -1, getDate()), -1)
Group By a.EquipNbr Order by a.EquipNbr Asc