Solved

Count unique field values grouped by mach

Posted on 2015-01-31
5
66 Views
Last Modified: 2015-02-02
Using the attached d/b I am trying to write a query that will give me the following:

Grouped by Machine

TestMachine1 - 123 = the result should be 2 because there are two of them for that machine
TestMachine1 - 234 = the result should be 3 because there are three of them for that machine
TestMachine1 - 564 = the result should be 2 because there are two of them for that machine
TestMachine2 - 589 = the result should be 3 because there are three of them for that machine
TestMachine2 - 849 = the result should be 1 because there is one of them for that machine
TestMachine2 - 956 = the result should be 2 because there are two of them for that machine

--Steve
Unique-Values.accdb
0
Comment
Question by:SteveL13
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:rspahitz
Comment Utility
One way is to create a calculated field that pulls out the machine name, something like:
Machine: Left(YourField, instr("-", YourField)

then sort on this calculated field (hidden) and show YourField
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
try this query


SELECT Table1.Machine, Table1.POn, Count(Table1.POn) AS CountOfPOn
FROM Table1
GROUP BY Table1.Machine, Table1.POn;
0
 

Author Comment

by:SteveL13
Comment Utility
Neither of these suggestions seem to work.  Again the result should be:

TestMachine1 - 123 = the result should be 2 because there are two of them for that machine
 TestMachine1 - 234 = the result should be 3 because there are three of them for that machine
 TestMachine1 - 564 = the result should be 2 because there are two of them for that machine
 TestMachine2 - 589 = the result should be 3 because there are three of them for that machine
 TestMachine2 - 849 = the result should be 1 because there is one of them for that machine
 TestMachine2 - 956 = the result should be 2 because there are two of them for that machine
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
i don't know what you were doing, but the query i posted above will give you this result

Machine                    POn   CountOfPOn
TestMachine 1    123      2
TestMachine 1    234      3
TestMachine 1    564      2
TestMachine 2    589      3
TestMachine 2    849      1
TestMachine 2    956      2
0
 

Author Closing Comment

by:SteveL13
Comment Utility
Worked.  I had a typo.  When I fixed it all was fine.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now