G
Guest
I have a table that has a number of fields in which there could be entries
from 1-11. also each participant has multiple rows for data entry (which was
an unfortunate result of having to work around access limitations on number
of fields)
How can I count up all the ‘1’s’ (or any other specific entry) over multiple
fields and rows? I've included more detail below for anyone who's kind enough
to answer below in case its handy!
a summary of the two different ways I have tried to do this already (I
haven’t included all the multiple fields in which the ‘1’ could be located
though):
SELECT StudyNumber,
Count(Mon_Assessment1) AS CountOfMon_Assessment1, Count(Mon_Assessment2) AS
CountOfMon_Assessment2…. And so on with more fields
FROM InterventionRecord
GROUP BY StudyNumber
WHERE (((Mon_Assessment1)="1")) OR (((Mon_Assessment2)="1")) … and so on
with more fields
This version returns counts of ALL entries (not just ‘1’s’)
I’ve also tried putting the critieria ‘1’ directly into the ‘count’ function
of the query which comes out very similar in the coding:
SELECT StudyNumber
Count(Mon_Assessment1) AS CountOfMon_Assessment1, Count(Mon_Assessment2) AS
CountOfMon_Assessment2…. And so on with more fields
FROM InterventionRecord
GROUP BY InterventionRecord.StudyNumber
HAVING (((Count(Mon_Intervention1))=1)) OR (((Count(Mon_Intervention2))=1))
… and so on with more fields
But this doesn’t return anything. I basically just want it to look at each
field in turn and count up the number of a specific entry i.e. 1, within that
field to give me the total number of ‘1’s in that field grouped by the study
number (primary key) to overcome the fact that i have more than one row per
patient. i’m thinking I may need to use IIf functions so that it looks at
each field individually and sums /counts if the entry is _ but I’ve no idea
how to go about writing this code. can anyone help please?!
from 1-11. also each participant has multiple rows for data entry (which was
an unfortunate result of having to work around access limitations on number
of fields)
How can I count up all the ‘1’s’ (or any other specific entry) over multiple
fields and rows? I've included more detail below for anyone who's kind enough
to answer below in case its handy!
a summary of the two different ways I have tried to do this already (I
haven’t included all the multiple fields in which the ‘1’ could be located
though):
SELECT StudyNumber,
Count(Mon_Assessment1) AS CountOfMon_Assessment1, Count(Mon_Assessment2) AS
CountOfMon_Assessment2…. And so on with more fields
FROM InterventionRecord
GROUP BY StudyNumber
WHERE (((Mon_Assessment1)="1")) OR (((Mon_Assessment2)="1")) … and so on
with more fields
This version returns counts of ALL entries (not just ‘1’s’)
I’ve also tried putting the critieria ‘1’ directly into the ‘count’ function
of the query which comes out very similar in the coding:
SELECT StudyNumber
Count(Mon_Assessment1) AS CountOfMon_Assessment1, Count(Mon_Assessment2) AS
CountOfMon_Assessment2…. And so on with more fields
FROM InterventionRecord
GROUP BY InterventionRecord.StudyNumber
HAVING (((Count(Mon_Intervention1))=1)) OR (((Count(Mon_Intervention2))=1))
… and so on with more fields
But this doesn’t return anything. I basically just want it to look at each
field in turn and count up the number of a specific entry i.e. 1, within that
field to give me the total number of ‘1’s in that field grouped by the study
number (primary key) to overcome the fact that i have more than one row per
patient. i’m thinking I may need to use IIf functions so that it looks at
each field individually and sums /counts if the entry is _ but I’ve no idea
how to go about writing this code. can anyone help please?!