Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting unique values

Status
Not open for further replies.

ferrisj

IS-IT--Management
Dec 7, 2004
79
US
I am trying to make a query that counts all of the unique values. However, which I put in the count function it does not count uniques it counts all of the records in the query. at the moment i have.

SELECT DISTINCTROW Count(individuals.INDID) AS CountOfINDID
FROM (ListDetail INNER JOIN (individuals LEFT JOIN Contact ON individuals.INDID = Contact.indid) ON ListDetail.Indid = individuals.INDID) LEFT JOIN ACARD ON individuals.INDID = ACARD.INDID
WHERE (((ListDetail.listdate)=#2/14/2005#) AND ((Contact.vote)="+")) OR (((ListDetail.listdate)=#2/14/2005#) AND ((ACARD.cardType)="a"));


Can anyone help with this?
 
You might try the following:

For Access 97:
[tt]
SELECT Count(Query1.INDID)
FROM
[SELECT DISTINCT individuals.INDID
FROM (ListDetail INNER JOIN (individuals LEFT JOIN Contact ON individuals.INDID = Contact.indid) ON ListDetail.Indid = individuals.INDID) LEFT JOIN ACARD ON individuals.INDID = ACARD.INDID
WHERE (((ListDetail.listdate)=#2/14/2005#) AND ((Contact.vote)="+")) OR (((ListDetail.listdate)=#2/14/2005#) AND ((ACARD.cardType)="a"));]. AS Query1;
[/tt]


For Access 2000+:
[tt]
SELECT Count(Query1.INDID)
FROM
(SELECT DISTINCT individuals.INDID
FROM (ListDetail INNER JOIN (individuals LEFT JOIN Contact ON individuals.INDID = Contact.indid) ON ListDetail.Indid = individuals.INDID) LEFT JOIN ACARD ON individuals.INDID = ACARD.INDID
WHERE (((ListDetail.listdate)=#2/14/2005#) AND ((Contact.vote)="+")) OR (((ListDetail.listdate)=#2/14/2005#) AND ((ACARD.cardType)="a"));) AS Query1;
[/tt]


See if this works for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top