Results 1 to 5 of 5
  1. #1
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60

    Query Help

    I have an Access database that has the following tables:
    tblEvent tblReviewer
    EventID(PK) ReviewerID (PK)
    EventTitle EventID (FK)
    EventDate ReviewerName
    Attended
    PrepTime

    One Event can have multiple Reviewers. The "Attended" field is a Y/N checkbox and "PrepTime" is the number of hours the reviewer spent preparing for the Event.
    It would look something like this:
    EventID EventTitle EventDate
    1 Event One 1/10/2013
    ReviewerID ReviewName Attended PrepTime
    01 Jane Doe Y 2
    02 John Doe N
    03 Another Name Y 6
    04 My Name Y 4
    EventID EventTitle EventDate
    2 Event Two 1/24/2013
    ReviewerID ReviewName Attended PrepTime
    05 Your Name Y 15
    06 Any Name Y 1



    I need to write a SQL query that lists each Event ID and Title, how many reviewers attended the event, and the total prep hours spent by all reviews for that event.
    Using the example above:
    EventID EventTitle Attended PrepTime
    1 Event One 3 12
    2 Event Two 2 16

    Can someone help please? Thanks!!!

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    This should work:

    Code:
    SELECT tblEvent.EventID, tblEvent.EventTitle, Count(tblReviewer.Attended) AS CountOfAttended, Sum(tblReviewer.PrepTime) AS SumOfPrepTime
    FROM tblEvent INNER JOIN tblReviewer ON tblEvent.EventID = tblReviewer.EventID
    GROUP BY tblEvent.EventID, tblEvent.EventTitle, tblReviewer.Attended
    HAVING (((tblReviewer.Attended)="Y"));

  3. #3
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60
    Thanks for the response, but I get the following error message when I try to run it:

    "Syntax error (missing operator) in query expression 'Sum(tblReviewer.PrepTime)'.

    Any ideas?
    Thanks!

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Don't know. Works for me. Look at my attachment. See if everything is the same.
    Attached Files Attached Files

  5. #5
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60
    Sorry, I found my mistake. Mistyped. Thanks, again!

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

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