Results 1 to 7 of 7
  1. #1
    adams.bria is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    22

    Counting Entries

    So I have a table where the key is Stuassn_ID

    This combines a DC_ID with a Stuterm_ID and a Occ_ID.
    The same DC_ID and Occ_ID can be assigned to any number of Stuterm_ID. However, each Stuterm_ID only has one DC_ID and Occ_ID.

    Basically there are eight unique Occ_ID's. I want to count how many of each Occ_ID have been assigned to each DC_ID.

    Let me know if anything needs clarification.

    Thanks,

    Brian

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Will this:

    Code:
     
    Select DC_ID, Count([Occ_ID])
    From [TableName]
    Group By DC_ID;
    Work?

  3. #3
    adams.bria is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    22
    Close but no cigar. If I am reading this right, it is counting how many occ_id's have been assigned to a DC_ID. I need to know how many of each unique occ_id's have been assigned to a DC_ID. In other words, how many 1's, how many 2's, how many 3's... for each DC_ID. Also this is a historical table so I added the part about aid year = aid year. But this is where we are at. Anyone know what to change to get to where I would like to be?

    Code:
    SELECT stu_assn.DC_ID, Count(stu_assn.[Occ_ID]) AS CountOfOcc_ID
    FROM (stu_assn INNER JOIN Dept_Cont ON stu_assn.DC_ID = Dept_Cont.DC_ID) INNER JOIN Local_Vars ON Dept_Cont.Aid_Year = Local_Vars.Aid_Year
    WHERE (([dept_cont].[aid_year]=[local_vars].[aid_year]))
    GROUP BY stu_assn.DC_ID;
    Last edited by adams.bria; 08-26-2011 at 09:50 AM. Reason: me

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    How about:

    Code:
     
    Select DC_ID, Occ_ID, Count(Occ_ID) AS NumberOfUniqueIDs
    From [TableName]
    Group By DC_ID, Occ_ID;
    ?

  5. #5
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    To use your SQL:

    Code:
     
    SELECT stu_assn.DC_ID, stu_assn.[Occ_ID], Count(stu_assn.[Occ_ID]) AS CountOfOcc_ID
    FROM (stu_assn INNER JOIN Dept_Cont ON stu_assn.DC_ID = Dept_Cont.DC_ID) INNER JOIN Local_Vars ON Dept_Cont.Aid_Year = Local_Vars.Aid_Year
    WHERE (([dept_cont].[aid_year]=[local_vars].[aid_year]))
    GROUP BY stu_assn.DC_ID, stu_assn.[Occ_ID];

  6. #6
    adams.bria is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2010
    Posts
    22
    Right on the money! Thanks, this forum is always amazing!

    ~Brian

  7. #7
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I've received a lot of help here myself so I'm happy to be able to help when I can.

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

Similar Threads

  1. Finding and counting (not records but entries)
    By gpbanseo in forum Queries
    Replies: 3
    Last Post: 07-14-2011, 04:35 AM
  2. counting days
    By d3pl0y3d in forum Access
    Replies: 13
    Last Post: 04-28-2011, 06:31 PM
  3. Counting Only Certain Records
    By jtphenom in forum Queries
    Replies: 9
    Last Post: 03-29-2011, 01:25 AM
  4. Counting
    By rfs in forum Forms
    Replies: 0
    Last Post: 03-15-2011, 03:20 PM
  5. Distinctive counting, can I do it?
    By Schon731 in forum Queries
    Replies: 5
    Last Post: 12-30-2010, 02:52 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