Thanks, Marsh. I agree with you fully. Unfortunately, I don't own the
db and can't change the tables.
With that being the case, do you think this would work? Or is there a
simpler way to handle this?
SELECT
(SELECT COUNT(Class1)
FROM tblTable1
WHERE tblTable1.Class1 = true)
AS Class1Count),
(SELECT COUNT(Class2)
FROM tblTable1
WHERE tblTable1.Class2 = true)
AS Class2Count),
(SELECT COUNT(Class3)
FROM tblTable1
WHERE tblTable1.Class3 = true)
AS Class3Count),
(SELECT COUNT(Class4)
FROM tblTable1
WHERE tblTable1.Class1 = true)
AS Class4Count)
FROM tblTable1
UNION
SELECT
(SELECT COUNT(Class1)
FROM tblTable2
WHERE tblTable1.Class1 = true)
AS Class1Count),
(SELECT COUNT(Class2)
FROM tblTable2
WHERE tblTable1.Class2 = true)
AS Class2Count),
(SELECT COUNT(Class3)
FROM tblTable2
WHERE tblTable1.Class3 = true)
AS Class3Count),
(SELECT COUNT(Class4)
FROM tblTable2
WHERE tblTable1.Class1 = true)
AS Class4Count)
Marshall Barton - 26 May 2006 15:59 GMT
>Thanks, Marsh. I agree with you fully. Unfortunately, I don't own the
>db and can't change the tables.
[quoted text clipped - 38 lines]
> WHERE tblTable1.Class1 = true)
> AS Class4Count)
I don't think that will do what I thought you wanted (even
after you fix the copy/paste name errors), because it will
return two sets of counts without regard to people that are
in both groups. You should try it yourself to see what you
get.
What I was suggesting is more like this (air code):
query - CombineGroups:
SELECT Class1, Class2, Class3, Class4
FROM tblTable1
UNION
SELECT Class1, Class2, Class3, Class4
FROM tblTable2
query - ClassCounts:
SELECT Count(Class1) As Class1Count,
Count(Class2) As Class2Count,
Count(Class3) As Class3Count,
Count(Class4) As Class4Count
FROM CombineGroups
I doubt this can be combined into a single query and can't
see a reason to even try.

Signature
Marsh
MVP [MS Access]