Results 1 to 3 of 3
  1. #1
    Lou-Jean is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Aug 2014
    Posts
    1

    Need to count on specific field in employee listing

    I have a file of Employee SSN, Last Name, First Name, Relationship. Relationship would be Employee, Spouse or Child.



    SSN Last_Name First_Name Rel_Cd
    123456789 LName Matthew Employee
    123456789 LName Mary Spouse
    123456789 LName Luke Child
    123456789 LName James Child


    For each Employee record, I need a count of Spouse and/or Child records related to that Employee SSN.
    I would prefer to retain all records, and just have the count listed next to the Employee in a new column.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    select SSN, count(SSN) as CountRelatives from tEmp where rel_cd <> "employee" group by SSN;

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    another approach; just make a query with SSN field only; press the big E sigma icon to make it an aggregate query where it will default the SSN field to 'Group By' and change that to Count. Because there must always be an employee all you need to do is subtract 1 from the count.......

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

Similar Threads

  1. Replies: 1
    Last Post: 04-04-2013, 11:59 AM
  2. Replies: 1
    Last Post: 03-13-2013, 12:00 PM
  3. Listing correct data in a field
    By Lois in forum Forms
    Replies: 1
    Last Post: 10-18-2011, 12:09 PM
  4. Count of field based on specific values
    By tazzmann67 in forum Access
    Replies: 2
    Last Post: 03-30-2011, 09:11 AM
  5. Qry that asks for specific employee name
    By oxicottin in forum Queries
    Replies: 0
    Last Post: 02-05-2007, 08:50 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