Solved

Count unique field values grouped by mach

Posted on 2015-01-31
5
71 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 40581706
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40581723
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
ID: 40583963
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40584204
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
ID: 40584211
Worked.  I had a typo.  When I fixed it all was fine.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

691 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