Hi,
The easiest way is to create a table that defines the groups:
AgeGroups ' table name
Starting, Ending Label 'field name
0 18 A
18 55 B
56 65 C
66 200 D ' data sample
Note that is it possible to have overlap or super groups, if that is
applicable to your solution (as example, a super group of all "American
states" is US, and a super group of all "Canadian provinces and territories"
is Canada, or a super group of 18-200 is those who can vote, etc. Anyhow,
once your groups are defined, use the like this:
SELECT AgeGroups.Label, SUM( myInitialTable.somethingToAdd)
FROM myInitialTable INNER JOIN AgeGroups
ON myInitialTable.Age >= AgeGroups.Starting
AND myInitialTable.Age <= AgeGroups.Ending
GROUP BY AgeGroups.Label
If your groups overlap, the SUM of, here, the second column, will exceed the
initial sum of individual data, but that is intended, as, for example, a
CUBE showing SUM, per state, then for the whole US.
Hoping it may help,
Vanderghast, Access MVP