sum of a unique value in a group

L

lstutchman

i'm trying to get a sum of yes, no and NA in a query over four different
fields. my table fields go like this [message] [callclose] [directory]
[signout]. each field has a value of yes, no or na. i'm trying to get a
count of how many yes, no and na in each field. is it possiable to do this in
a query?
 
M

Marshall Barton

lstutchman said:
i'm trying to get a sum of yes, no and NA in a query over four different
fields. my table fields go like this [message] [callclose] [directory]
[signout]. each field has a value of yes, no or na. i'm trying to get a
count of how many yes, no and na in each field. is it possiable to do this in
a query?


Kind of ugly, but it will do it:

SELECT Sum(IIf([message] = "Yes", 1, 0)) As MsgYes,
Sum(IIf([message] = "No", 1, 0)) As MsgNo,
Sum(IIf([message] = "NA", 1, 0)) As MsgNA,
Sum(IIf([callclose] = "Yes", 1, 0)) As CallYes,
. . .
FROM thetable

There's probably a way to use a cross tab query that
wouldn't be so tedious, but I'm not sure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top