On Mon, 12 Jul 2010 13:28:18 -0700 (PDT), Jeffrey Marks <(E-Mail Removed)>
wrote:
>
>I have a table that has 5 different test scores (reading, writing,
>math, SS, and science) per records in the table. The student may take
>these tests multiple times (until passed). So a test score may have a
>score (1-600) in the field or it may be null.
>
>I'd like to total the number of time each student takes a given test
>(e.g. how many times did he/she take the math test). When I'm done I
>also want to see how many tests were taken, but if I have the total
>count of how many times each test was taken, I can easily sum those to
>get the overall total.
>
>Is the best way to approach this an IIF statement, stating that if the
>score is not one add 1 to the total? Or is there a more efficient way
>to code this?
>
>Thanks as always
>
>Jeff
If you have one field for each test, your table isn't properly designed! A
better structure would have one record per test result - fields for the
student ID, the test ID, perhaps the date taken and the score.
With your current design how do you handle the case where a student passes
reading on the first try, but has to take math three times? Do you have two
records with null Reading scores?
If you want to count the number of non-NULL results for each test, you can use
a totals query:
SELECT StudentID, Sum(IIF(IsNull([Reading]), 0, 1)) AS CountOfReading,
Sum(IIF(IsNull([Writing]), 0, 1)) AS CountOfWriting, <etc>
Am I understanding the table structure correctly? If not could you post some
sample data?
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also
http://www.utteraccess.com