Solved

Unique Count

Posted on 2003-10-22
4
1,751 Views
Last Modified: 2012-06-27
Hi,                              
I have pasted some sample data. I am trying to get a unique count of the months per person. ID is unique and the primary key. More details below.                              
                              
                              
ID                 FIRSTNAME      LASTNAME        Month         VISITS        
2296015955      MAX      SMART      Feb-03      1
2296015955      MAX      SMART      Jan-03      2
2296015955      MAX      SMART      May-02      2
2296015955      MAX      SMART      Oct-02      2
2296016405      JOHN      SMART      Jun-02      2
2296016405      JOHN      SMART      May-03      2
2296086814      TEX      JONES      May-03      2
2296088711      FRANK      FLOYE      Jan-03      6
2296088711      FRANK      FLOYE      Mar-03      2
2296088711      FRANK      FLOYE      May-02      2

                              
Here you can see Max Smart has had 1 visit in Feb 2003, 2 in Jan 2003 2 in May 2002 and                              
2 in October 2002. I got this by doing a Count function in Access.                              
What I need now is to find out the number of months Max Smart had visits in.                               
In this case it would be 4 ( Jan 03, Feb 03, May 02 and Oct 02)                              
For John Smart it would be 2 ( June 02 , May 03)                              
For Tex Jones it would be 1 ( May 03)                              
For Frank Floye it would be 3 ( Jan 03, March 03, May 02)                              
                              
I cannnot do a Count for this because a person may have multiple visits in a month.                              
My goal is to find the number of months per person. How can I do this in Access.                              
Would appreciate any help.                              
Thanks,                              
GuruGanta                              
0
Comment
Question by:guruganta
[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
4 Comments
 
LVL 17

Expert Comment

by:walterecook
ID: 9600495
Create a query that groups on Id, FirstName, LastName, and Month
(add those fields and Click the Sigma in the toolbar)
Add an additional field called Month.
In the total row for the second Month column, change it to "Count"

That should do it
Walt
0
 
LVL 17

Expert Comment

by:walterecook
ID: 9600504
Whoops I lied.
However that query is still useful.  Use that query as a source for another query.  In the new query do a count on months.

Sorry for the mixup
Walt
0
 
LVL 1

Accepted Solution

by:
rikky_b earned 250 total points
ID: 9600658
Hi GuruGanta,
Here's a query statement you can use

SELECT DISTINCT Count(Month([month])) AS CountofMonthsVisited, visit_table.id, visit_table.firstname, visit_table.lastname
FROM visit_table
GROUP BY visit_table.id, visit_table.firstname, visit_table.lastname;

Note that I used a fictional table name 'visit_table' which has an identical structure to the data you provided above.
Let me know if this isn't exactly what you're looking for.

Eric
0
 

Author Comment

by:guruganta
ID: 9602088
Eric,

Thanks for the input Walter and Eric. I was able to apply Eric's solution. I am awarding him the points.
I appreciate the help, Walter and Eric.
Muchos Gracias.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 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