A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

In crosstab query, how do I count not including duplicates?



 
 
Thread Tools Display Modes
  #1  
Old February 25th, 2010, 04:38 PM posted to microsoft.public.access.queries
Ojoj
external usenet poster
 
Posts: 1
Default In crosstab query, how do I count not including duplicates?

I have a table which lists contacts with people including the field
'FamilyID'. I want to count the number of different families the
organisation has had contact during a quarter with a crosstab query. If I
use the Count function it double counts families we have seen twice, so
showing us the overall number of contacts, but not the number of families we
had contact with.
  #2  
Old February 25th, 2010, 05:55 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default In crosstab query, how do I count not including duplicates?

Post your crosstab query SQL and sample data with example of what the output
should look like.

--
Build a little, test a little.


"Ojoj" wrote:

I have a table which lists contacts with people including the field
'FamilyID'. I want to count the number of different families the
organisation has had contact during a quarter with a crosstab query. If I
use the Count function it double counts families we have seen twice, so
showing us the overall number of contacts, but not the number of families we
had contact with.

  #3  
Old February 25th, 2010, 07:43 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default In crosstab query, how do I count not including duplicates?

You need to do a two-step process.

First build a query that returns unique records. Something like

SELECT Distinct ContactID
, Year(MeetingDate) as TheYear
, DatePart("q",MeetingDate) as TheQuarter
FROM ContactsTable

NOW use that to build your crosstab query.
TRANSFORM Count(ContactID)
SELECT TheYear
FROM TheSaveQuery
GROUP BY TheYear
PIVOT TheQuarter



John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Ojoj wrote:
I have a table which lists contacts with people including the field
'FamilyID'. I want to count the number of different families the
organisation has had contact during a quarter with a crosstab query. If I
use the Count function it double counts families we have seen twice, so
showing us the overall number of contacts, but not the number of families we
had contact with.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.