The below Union Query comes from two basically identical queries. One lists a group of buildings with a count of inspection done within a certain range. The other lists a group of building that did not have inspections done during that range.
My purpose is this. I need to do a report on all the buildings that are due inspections for the quarter. It was easy enough to see the status on the ones that had at least one inspection done during the quarter but for those who did not have an inspection done the initial query did not pull up the building. I ended up making 5 total queries (including the union) to get this to work and of course I have duplicates due to the union of the final two queries. There has to be a simlar way to do this.
Any suggestions or help would be appreciated.
SELECT Q_PI_Qrtly_Insp_Ct_Range.District, Q_PI_Qrtly_Insp_Ct_Range.Bldg_Number, Q_PI_Qrtly_Insp_Ct_Range.Bldg_Name, Q_PI_Qrtly_Insp_Ct_Range.Address, Q_PI_Qrtly_Insp_Ct_Range.City, Q_PI_Qrtly_Insp_Ct_Range.State, Q_PI_Qrtly_Insp_Ct_Range.FSL, " " AS InspDateBlank, Sum(Q_PI_Qrtly_Insp_Ct_Range.InspDateCt) AS SumOfInspDateCt, Q_PI_Qrtly_Insp_Ct_Range.Due
FROM Q_PI_Qrtly_Insp_Ct_Range
GROUP BY Q_PI_Qrtly_Insp_Ct_Range.District, Q_PI_Qrtly_Insp_Ct_Range.Bldg_Number, Q_PI_Qrtly_Insp_Ct_Range.Bldg_Name, Q_PI_Qrtly_Insp_Ct_Range.Address, Q_PI_Qrtly_Insp_Ct_Range.City, Q_PI_Qrtly_Insp_Ct_Range.State, Q_PI_Qrtly_Insp_Ct_Range.FSL, Q_PI_Qrtly_Insp_Ct_Range.Due;
UNION SELECT Q_PI_Qrtly_Insp_Ct_Range_Null.District, Q_PI_Qrtly_Insp_Ct_Range_Null.Bldg_Number, Q_PI_Qrtly_Insp_Ct_Range_Null.Bldg_Name, Q_PI_Qrtly_Insp_Ct_Range_Null.Address, Q_PI_Qrtly_Insp_Ct_Range_Null.City, Q_PI_Qrtly_Insp_Ct_Range_Null.State, Q_PI_Qrtly_Insp_Ct_Range_Null.FSL, " " AS InspDateSpace, " " AS CountSpace, Q_PI_Qrtly_Insp_Ct_Range_Null.Due
FROM Q_PI_Qrtly_Insp_Ct_Range_Null
GROUP BY Q_PI_Qrtly_Insp_Ct_Range_Null.District, Q_PI_Qrtly_Insp_Ct_Range_Null.Bldg_Number, Q_PI_Qrtly_Insp_Ct_Range_Null.Bldg_Name, Q_PI_Qrtly_Insp_Ct_Range_Null.Address, Q_PI_Qrtly_Insp_Ct_Range_Null.City, Q_PI_Qrtly_Insp_Ct_Range_Null.State, Q_PI_Qrtly_Insp_Ct_Range_Null.FSL, Q_PI_Qrtly_Insp_Ct_Range_Null.Due;