Results 1 to 5 of 5
  1. #1
    Lynn Cohen is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    30

    COUNT function help needed

    I am working on schedule data at a college using an Access 2010 database. I'm somewhat new to Access 2010, but have used Access 2003 for several years.

    I have a table that holds records for each course that has run in a year. A course can be run several times in a year, and so most courses have more than one section number. For example, there may be ACC 101-01, ACC 101-02, and ACC 102-03, where ACC 101 and ACC 102 are course numbers and 01, 02, 03 are section numbers.

    I want to count, by course number, the numbers of sections that actually ran, for a year. The results I want would look like:


    ACC 101 2
    ACC 102 1

    I created Query 1, which returns each course with all its section numbers for the year. I deselected sections that were cancelled. Example: ACC 101-04 was cancelled, and so was deselected.

    I copied Query 1 to create Query 2. In Query 2 I applied the COUNT function to the section numbers column. The numbers I am getting (as confirmed by a manual count) indicate the sections I deselected in Query 1 are no longer deselected. Example: I am getting a total of 3 for ACC 101.

    Would appreciate any pointers. Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    How did you 'deselect' record? What is the filter criteria? Is there a 'Cancelled' field?

    The course/section value is all in one field?

    Show the attempted query SQL statement. Something like:

    SELECT Left([Course],7) AS CourseID, Count(Right([Course],2)) AS Section WHERE Cancelled = False GROUP BY Left([Course,7);
    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.

  3. #3
    Lynn Cohen is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    30
    >>How did you 'deselect' record? What is the filter criteria? Is there a 'Cancelled' field?
    Records for cancelled sections have a unique "Faculty ID" number, number 261. In Query 1, I set a parameter in the "Faculty ID" field that says not 261.

    >>The course/section value is all in one field?
    "Course" and "Section Number" are two separate fields.

    >>Show the attempted query SQL statement.
    I don't have an SQL statement. In Design View, I clicked on the "sum" sign in the Show/Hide tab which added a row called "Show" to the Design View. This puts a qualifier, "Where" in each column. In the column for "Section Number" I changed the qualifier "Where" to "Count."

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    You said you built Query1 and Query2. If you did build queries then there is SQL statement. It can be seen in the SQL View of the query builder. Copy/paste in post so we can analyze.

    What you describe is an aggregate (GROUP BY) Totals query.

    Consider building a report using Grouping & Sorting with aggregate calcs in footer sections. This allows display of detail records as well as summary data.
    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.

  5. #5
    Lynn Cohen is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    30
    Quote Originally Posted by June7 View Post
    You said you built Query1 and Query2. If you did build queries then there is SQL statement. It can be seen in the SQL View of the query builder. Copy/paste in post so we can analyze.

    What you describe is an aggregate (GROUP BY) Totals query.

    Consider building a report using Grouping & Sorting with aggregate calcs in footer sections. This allows display of detail records as well as summary data.
    ******************************************
    Thanks to everyone who replied.

    I was able to set up a series of queries that performed the calculations I need.

    • Query 1 identifies all sections of each course.
    • Query 2 counts numbers of sections per course.
    • Query 3 identifies all sections of each course that ran in the online format.
    • Query 4 counts numbers of online sections per course.
    • Query 5 returns: course number, # sections identified in Query 2, # sections identified in Query 4.


    This format allows me to de-select certain sections we don't want to count, in Query 1 and Query 3.

    Lynn

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

Similar Threads

  1. COUNT Group Count Records COUNT FUNCTION
    By PMCOFFEY in forum Access
    Replies: 9
    Last Post: 11-09-2012, 09:40 PM
  2. Odd Averaging Function Needed
    By Heatshiver in forum Programming
    Replies: 2
    Last Post: 03-20-2012, 08:26 PM
  3. Count + between + parameter function
    By teirrah1995 in forum Queries
    Replies: 3
    Last Post: 08-11-2011, 10:25 AM
  4. Help needed in modifying Function
    By Alex Motilal in forum Programming
    Replies: 4
    Last Post: 02-06-2011, 11:59 PM
  5. Query using count function
    By wasim_sono in forum Queries
    Replies: 0
    Last Post: 11-28-2007, 03:16 AM

Tags for this Thread

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