Results 1 to 2 of 2
  1. #1
    al_mamun is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2013
    Posts
    2

    How to add a calculated field (Quiz Total) in the following query


    ST ID SUB ID Quiz 1 Quiz 2 Quiz 3 Quiz 4 Quiz 5 Quiz Total (Best 3 )
    0111 Maths 9 9 9 10 10
    0111 Eng. I 9 7 7 8 9
    0111 Eng II 10 8.5 7 8 8.5
    0111 Eng. Lit. 9.5 9.5 8 8.5 8

    How can I calculate the Quiz Total field that is the addition of the best three quizzes.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Adding 5 fields is a simple expression. Complication is the 'Best 3' requirement.

    That is not normalized data structure. This link http://support.microsoft.com/kb/209839/en-us has various function for aggregating row data, however, it doesn't handle your 'Best 3' parameter. That will require more code.

    Another method is with UNION query to get the data into a normalized structure then use that query as source for subsequent queries.

    SELECT [St ID], [Sub ID], [Quiz 1] As Score, "1" As Quiz FROM tablename
    UNION SELECT [St ID], [Sub ID], [Quiz 2], "2" FROM tablename
    UNION SELECT [St ID], [Sub ID], [Quiz 3], "3" FROM tablename
    UNION SELECT [St ID], [Sub ID], [Quiz 4], "4" FROM tablename
    UNION SELECT [St ID], [Sub ID], [Quiz 5], "5" FROM tablename;

    There is no wizard for UNION query, type or copy/paste in SQL View of query builder.

    Then you need a query to select the top 3 http://allenbrowne.com/subquery-01.html#TopN and then a query to aggregate (or build a report).

    BTW, recommend no spaces in names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calculated Field with Running Cummulative Total!
    By countingguru in forum Access
    Replies: 4
    Last Post: 06-22-2020, 08:36 AM
  2. Replies: 3
    Last Post: 02-13-2013, 10:15 AM
  3. Calculated Total with beginning Value
    By mcahal in forum Access
    Replies: 1
    Last Post: 01-03-2012, 11:46 AM
  4. Total Query(One field with Null value)
    By vidplaylist in forum Queries
    Replies: 1
    Last Post: 11-30-2011, 03:57 PM
  5. Match-Up Quiz
    By nikgupta in forum Access
    Replies: 3
    Last Post: 11-21-2011, 03:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums