PC Review


Reply
Thread Tools Rate Thread

Counting fields in a table row

 
 
Jeffrey Marks
Guest
Posts: n/a
 
      6th Apr 2011
Hi

I got an Access database from the government. It's by no means optimal. They have a table of test scores that looks like this:

Student Number
MathTestScore2009-2010
ReadingTestScore2009-2010
MathTestScore2008-2009
ReadingTestScore2008-2009
(and then continued for earlier years)

my query needs to check all years and see if the score for each test (Math,reading, etc) is greater than 400. If it is, then I need to add 1 to the total tests passed. Otherwise not. Also if they passed the test in 2008-2009, the score for 2009-2010 will be blank/null because they no longer need totake the test once they pass.

Is there a way to do this using a table with the above format? Or should I put the time in (and time is very tight on this phase of the project) to optimize the database and then try this? What design would best suit these fields, by year or by test?

Thanks

Jeff
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      7th Apr 2011
On Wed, 6 Apr 2011 15:42:19 -0700 (PDT), Jeffrey Marks <(E-Mail Removed)>
wrote:

>Hi
>
>I got an Access database from the government. It's by no means optimal. They have a table of test scores that looks like this:
>
>Student Number
>MathTestScore2009-2010
>ReadingTestScore2009-2010
>MathTestScore2008-2009
>ReadingTestScore2008-2009
>(and then continued for earlier years)
>
>my query needs to check all years and see if the score for each test (Math, reading, etc) is greater than 400. If it is, then I need to add 1 to the total tests passed. Otherwise not. Also if they passed the test in 2008-2009, the score for 2009-2010 will be blank/null because they no longer need to take the test once they pass.
>
>Is there a way to do this using a table with the above format? Or should I put the time in (and time is very tight on this phase of the project) to optimize the database and then try this? What design would best suit these fields, by year or by test?
>
>Thanks
>
>Jeff


EEeeeeuwwww... your tax dollars at work. That's UGLY.

What you can do to extract the data into a tall-thin normalized structure is
a UNION query: something like

SELECT StudentNumber, "Math" AS Test, "2009-2010" AS Testyear,
[MathTestScore2009-2010] AS Score FROM yourtable
WHERE [MathTestScore2009-2010] IS NOT NULL
UNION ALL
SELECT StudentNumber, "Math" AS Test, "2008-2009" AS Testyear,
[MathTestScore2008-2009] AS Score FROM yourtable
WHERE [MathTestScore2008-2009] IS NOT NULL
UNION ALL
SELECT StudentNumber, "Reading" AS Test, "2009-2010" AS Testyear,
[ReadingTestScore2009-2010] AS Score FROM yourtable
WHERE [ReadingTestScore2009-2010] IS NOT NULL
UNION ALL
SELECT StudentNumber, "Reading" AS Test, "2008-2009" AS Testyear,
[ReadingTestScore2008-2009] AS Score FROM yourtable
WHERE [ReadingTestScore2008-2009] IS NOT NULL
UNION ALL
<etcetera through all the fields>

You can then base a totals query on this stored UNION query.
--

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
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
counting yes/no fields Joachim Microsoft Access Queries 3 5th Oct 2009 04:36 PM
Counting fields on criteria in other fields buattis@anz.com Microsoft Excel Worksheet Functions 1 31st Oct 2007 12:22 AM
Counting Across Fields Mike DeNuccio Microsoft Access Queries 2 28th Mar 2004 07:59 PM
How to update values in fields from one table to same fields in another Table Microsoft Access 1 7th Jan 2004 10:35 PM
Counting Table Fields John Microsoft Access Macros 1 8th Jul 2003 05:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:10 PM.