Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count of records from multiple columns 1

Status
Not open for further replies.

dbero

Technical User
Mar 31, 2005
109
US
[highlight #FCE94F][/highlight]

Hello,

I have a table that has test results in it. Each question is a column, and each row is the demographic/date information.
It basically looks like this.
Name TestDate Question 1 Qestion 2 Question 3
Tom 3/15/2013 Correct Correct Fail
Dick 4/1/2013 Fail Correct Fail
Harry 5/2/2013 Correct Correct Correct

What I need to do is to calculate the total pass/fail ratio for the entire test. So i need a query that adds up count of Fails from every question, and also adds up the count of corrects from every question. I then of course want to calculate the score. Is there an easy way to do this with a minimal number of queries? I don't want to have a pass and fail query for each question.
thank you!!!!

 
You could begin by creating a normalizing union query with SQL something like:

SQL:
SELECT [Name], TestDate, Question1 as Answer, 1 as Question
FROM tblUnnormalized
UNION ALL
SELECT [Name], TestDate, Question2, 2
FROM tblUnnormalized
UNION ALL
SELECT [Name], TestDate, Question3, 3
FROM tblUnnormalized;

You can then do a simple totals query.

Duane
Hook'D on Access
MS Access MVP
 
Thank you very much. i will give that a try tomorrow!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top