Need Help On How To Do Counts by Uniques

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nanao56
    New Member
    • Aug 2008
    • 3

    Need Help On How To Do Counts by Uniques

    This sounds simple, so I'm sure I'm just not getting it on how to use Access. I'm using Access 2007

    What I'm trying to do is get a unique count of People by ProjectName

    Example of the data set

    ProjectName | Person | Action
    Opus | John | Piano
    Violet | Mark | Violin
    Violet | Mark | Guitar
    Mozart | Sandy | Flute
    Mozart | Mark | Violin
    Mozart | Mark | Guitar

    The result should look like

    ProjectName | Count of People
    Opus | 1
    Violet | 1
    Mozart | 2

    Can anyone help?

    Thanks

    Raymon
  • rsmccli
    New Member
    • Jan 2008
    • 52

    #2
    Originally posted by nanao56
    This sounds simple, so I'm sure I'm just not getting it on how to use Access. I'm using Access 2007

    What I'm trying to do is get a unique count of People by ProjectName

    Example of the data set

    ProjectName | Person | Action
    Opus | John | Piano
    Violet | Mark | Violin
    Violet | Mark | Guitar
    Mozart | Sandy | Flute
    Mozart | Mark | Violin
    Mozart | Mark | Guitar

    The result should look like

    ProjectName | Count of People
    Opus | 1
    Violet | 1
    Mozart | 2

    Can anyone help?

    Thanks

    Raymon
    You will want to create a query and use aggregate functions. If you create a query on your table(s) in the graphical query designer, right click in the bottom part and select 'Totals'. Another row of choices will appear. This one's pretty simple, so I would just fool around with the 'Group By' and 'Count' choices. It will be good practice since you are just starting out.

    hth,
    rsmccli

    Comment

    • nanao56
      New Member
      • Aug 2008
      • 3

      #3
      Originally posted by rsmccli
      You will want to create a query and use aggregate functions. If you create a query on your table(s) in the graphical query designer, right click in the bottom part and select 'Totals'. Another row of choices will appear. This one's pretty simple, so I would just fool around with the 'Group By' and 'Count' choices. It will be good practice since you are just starting out.

      hth,
      rsmccli
      Hi! Thanks for replying back.

      Any idea on how the SQL would look like?

      Comment

      • nanao56
        New Member
        • Aug 2008
        • 3

        #4
        For the benefit of other users, I got help from someone else. It was simpler than what I thought it was.

        Code:
        SELECT ProjectName, COUNT(*) As CountOfPeople
        FROM (SELECT ProjectName, Person FROM tblTableName GROUP BY ProjectName, Person)
        GROUP BY ProjectName

        Comment

        Working...