Results 1 to 3 of 3
  1. #1
    mcchung52 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    15

    counting fields

    Hello all,
    I'm currently working with a long list of records containing people's names
    and their affliated facilities.

    field1 contains facility name
    field8 contains people name
    field15 contains city where they live in


    in the list, each individual will have different products serviced
    e.g
    field1 ... field8 ... field15
    === === ====
    A smith product1 New York
    A smith product2 New York
    A ronald product1 New Jersey
    B cheng product3 Boston

    I have a following query to pull a report
    where I want to count how many products each individual
    has taken.

    SELECT DISTINCT field1, field8, count(field8), field15
    FROM sheet1
    GROUP BY field8
    ORDER BY field15, field1;

    Am I doing something wrong? I can't even get it to show.
    Any pointer will be appreciated. Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    You don't include the product field in the query. How are the facility and city relevant if you want count of products per individual?

    SELECT field8, Count(product) As ProdCt FROM sheet1 GROUP BY field8;

    Alternatively, don't do aggregate calcs in query. Build report and use it's grouping & sorting with aggregate calcs functionality. This allows display of detail records and summary data in headers/footers.
    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
    mcchung52 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    15
    I sort of achieved what I want with the following query:

    SELECT DISTINCT field1, field8, count(field8), field15
    FROM sheet1
    GROUP BY field1, field8, field15
    ORDER BY field15, field1;

    field15, city, is just city not really relevant in terms of how I want to combine data.
    just realized you need to include all fields in the SELECT in the GROUP BY section. Is this correct?

    -"Alternatively, don't do aggregate calcs in query. Build report and use it's grouping & sorting with aggregate calcs functionality."
    Can you elaborate what you mean here? Thanks.

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

Similar Threads

  1. Counting Yes No Fields
    By pwilson in forum Queries
    Replies: 3
    Last Post: 11-29-2011, 10:29 AM
  2. Counting only 'checked' Yes/No fields on a
    By pwdpwd in forum Programming
    Replies: 9
    Last Post: 04-14-2011, 09:28 AM
  3. Replies: 4
    Last Post: 04-09-2011, 10:39 AM
  4. Counting
    By rfs in forum Forms
    Replies: 0
    Last Post: 03-15-2011, 03:20 PM
  5. Counting across multiple fields
    By shak2 in forum Programming
    Replies: 37
    Last Post: 10-20-2010, 10:20 AM

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