PC Review


Reply
Thread Tools Rate Thread

Counting unique values in main table

 
 
Ngan Bui
Guest
Posts: n/a
 
      31st Jan 2004
I have two tables, tblComplaint linked one to many to
tblCompResponse.

In one summary report, they want a count of complaints
where the response is not closed (responsedate is not
null) and another count where the response is closed.

If a complaint has two responses that are closed, that
complaint should be counted only once.

On the same report, they want to count the complaints that
have the investigation done (investclosedate is not null),
but the final response isn't (responsedate is null). but
you can have two responses that are done and I only need
it to be counted once.

I tried a query where the two tables are linked...but then
it would count a comp twice if it has multiple responses.

Is there any easy way to do this?
 
Reply With Quote
 
 
 
 
Bryan Reich [MSFT]
Guest
Posts: n/a
 
      4th Feb 2004
Select only the fields you are interested in, do not select the unique IDs
for the response table as returned values, and then write the query starting
as follows:

SELECT DISTINCT *other stuff goes here*

This should remove any return rows that are duplicates.

ExampleQuery:

SELECT DISTINCT PrimaryTable.string
FROM PrimaryTable, SecondaryTable
WHERE PrimaryTable.ID=SecondaryTable.primID and NOT
IsNull(SecondaryTable.someDate);
--
Bryan Reich
Microsoft Office
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Ngan Bui" <(E-Mail Removed)> wrote in message
news:70db01c3e787$596701f0$(E-Mail Removed)...
> I have two tables, tblComplaint linked one to many to
> tblCompResponse.
>
> In one summary report, they want a count of complaints
> where the response is not closed (responsedate is not
> null) and another count where the response is closed.
>
> If a complaint has two responses that are closed, that
> complaint should be counted only once.
>
> On the same report, they want to count the complaints that
> have the investigation done (investclosedate is not null),
> but the final response isn't (responsedate is null). but
> you can have two responses that are done and I only need
> it to be counted once.
>
> I tried a query where the two tables are linked...but then
> it would count a comp twice if it has multiple responses.
>
> Is there any easy way to do this?



 
Reply With Quote
 
Shaun
Guest
Posts: n/a
 
      5th Feb 2004
Group the data first before counting on it.


>-----Original Message-----
>I have two tables, tblComplaint linked one to many to
>tblCompResponse.
>
>In one summary report, they want a count of complaints
>where the response is not closed (responsedate is not
>null) and another count where the response is closed.
>
>If a complaint has two responses that are closed, that
>complaint should be counted only once.
>
>On the same report, they want to count the complaints

that
>have the investigation done (investclosedate is not

null),
>but the final response isn't (responsedate is null). but
>you can have two responses that are done and I only need
>it to be counted once.
>
>I tried a query where the two tables are linked...but

then
>it would count a comp twice if it has multiple responses.
>
>Is there any easy way to do this?
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting Unique Values Karen Microsoft Excel Worksheet Functions 4 20th Oct 2009 06:11 PM
Excel Pivot Table - Counting Unique Values within one column of da GBONDI Microsoft Excel Worksheet Functions 1 22nd Jan 2009 02:26 PM
Counting unique values in a table BRob Microsoft Excel Misc 6 3rd Apr 2008 06:46 PM
Counting unique values and all values in same query John Morrissey Microsoft Access Queries 1 6th Aug 2004 01:14 PM
Counting unique values Howard Pain Microsoft Excel New Users 2 13th Mar 2004 06:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:24 PM.