Hey Guru's,I have:SELECT ca.Id, ca.category, SUM(o.total) as recs FROM( SELECT p.cmpID, p.categoryID, COUNT(p.categoryID) AS total FROM products p GROUP BY p.cmpID, p.categoryID UNION SELECT w.cmpID, w.categoryID, COUNT(w.categoryID) AS total FROM WH_types w GROUP BY w.cmpID, w.categoryID)o INNER JOIN Categories ca ON ca.Id = o.categoryID INNER JOINcompanyProperties ON o.cmpID = companyProperties.CmpIdWHERE o.cmpID = 160 GROUP BY ca.Id, ca.category
The problem is the counts are wrong when the union tables share a category ID. I presume this is because I group by categoryID.Is there away around this?