I'm a bit confused as to why you used the Sum function instead of the Count
function in the first part. I would think that a Sum can only be performed
on a field that contains a number not a letter as I understood the original
question. Am I incorrect in my assumption? I have a very similar problem in
that I have a Gender field that contains an "m" or "f" and I need to know how
many M's there are, and separately, how many F's there are. I figure I'd put
the answers in an alias called Males and Females respectively. This seems
like basically the same problem but I guess I'm not sure how the
Abs(Sum([X]='A') As CountOfAs,
Abs(Sum([X]='B') As CountOfBs,
Abs(Sum([X]='C') As CountOfCs,
parts work.
--
Sometimes I wonder if men and women really suit each other. Perhaps they
should live next door and just visit now and then.
Dirk Goldgar said:
John said:
Hi
I have a field that can have either A, B or C as its value. I need to
write a query that will return the number of A's, B's & C's in the
field X for a given criteria and then the total records for the same
criteria. How do I write such as query?
Here's example SQL (untested):
SELECT
Abs(Sum([X]='A') As CountOfAs,
Abs(Sum([X]='B') As CountOfBs,
Abs(Sum([X]='C') As CountOfCs,
Count(*) As TotalCount
FROM [TheTable]
WHERE SomeField = SomeCriterion;
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)