Help with multiple count query

G

Greg Denehy

Hi all,
Can someone please give me a hand with this query?

I have this table:

AnswerTable
[SurveyID]
[QuestionID]
[Answer]

I need to get a percentage count when the answer is 1 to questionID 29, but
grouped by Answer of QuestionID 2

That probably doesnt make sense.

I need to say basically this: SELECT count(answer=1 AND
QuestionID=29),Answer(WHEN Question ID = 2) FROM AnswerTable WHERE
QuestionID=2
Group by Answer

Hope ou can help.

Greg
 
J

JohnFol

Can I presume the SurveyID & QuestionID form the primary key?

You need to do this by re-adding the table into the query grid.

This isn't a complete solution, but it does give you the columns for both
questions in the same place

SELECT AnswerTable.SurveyID, AnswerTable.QuestionID, AnswerTable.Answer,
AnswerTable_1.QuestionID, AnswerTable_1.Answer
FROM AnswerTable LEFT JOIN AnswerTable AS AnswerTable_1 ON
AnswerTable.SurveyID = AnswerTable_1.SurveyID
WHERE (((AnswerTable.QuestionID)=29) AND ((AnswerTable_1.QuestionID)=2));

For simplicity, save this as a query, and use it as the input into a new
query where you do the grouping.

Regards
 

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