Help creating a "count" query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emandel
    New Member
    • Dec 2006
    • 65

    Help creating a "count" query

    I have a db with a table called "events" a table "participan ts" and the table linking them together is "attendance " this gives me a many to many relationship. I first record in a form the nature of the event and then record who from the "participan ts" attended each event.

    I would like to create a query, whereby at each event it counts the attendees that came. Please can someone walk me through this.

    Thank you,
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by emandel
    I have a db with a table called "events" a table "participan ts" and the table linking them together is "attendance " this gives me a many to many relationship. I first record in a form the nature of the event and then record who from the "participan ts" attended each event.

    I would like to create a query, whereby at each event it counts the attendees that came. Please can someone walk me through this.

    Thank you,
    ASSUMPTIONS:
    1. Attendance is the Linking Table with a Composite Primary Key consisting of the [EventID] and [ParticipantID] Fields, with the following Relationships defined:
      1. Events.[EventID](1) ==> Attendance.[EventID](MANY)
      2. Participants.[ParticipantID](1) ==> Attendance.[ParticipantID](MANY)
    2. The SQL for determining the Count of Attendees per Event, by Event Name, would be (assumes a Name Field exists in the Events Table:
      [CODE=sql]SELECT Events.Name, Count(Attendanc e.EventID) AS Total_Attending
      FROM Events INNER JOIN Attendance ON Events.EventID = Attendance.Even tID
      GROUP BY Events.Name;[/CODE]

    Comment

    • emandel
      New Member
      • Dec 2006
      • 65

      #3
      Thank you that worked!

      Comment

      Working...