Quantity query

  • Thread starter Thread starter woods1119
  • Start date Start date
W

woods1119

I would like "ysnACR" to =1 in this query but am not sure how to write it.

SELECT ingPtID, COUNT (ysnACR)
As Quantity
FROM tVisit
Group By ingPtID

Thanks!
 
I would like "ysnACR" to =1 in this query but am not sure how to write it.

SELECT ingPtID, COUNT (ysnACR)
As Quantity
FROM tVisit
Group By ingPtID

Thanks!

I have NO trace of an idea what you mean.

Count() counts non-null values in a table field. What are you trying to count?
If you just want to coung the number of records for each ingPtID, use
Count(*).
 
I would like to count how many times ingPtID has had ysnACR equaling the
criteria of "1" in tVisit.

I've had success using this query to count the number of records for ingPtID
in other tables as you stated but this is the first time I'm trying to count
the number of times a field has the criteria of "1" in this table.

Do you suggest setting writing it another way?
 
If I understand, you want to count he number of times ysnAcr is equal to 1 for
each ingPtId value. If so try one of the following queries.

SELECT ingPtID
, Count(ysnACR) As Quantity
FROM tVisit
WHERE ysnAcr = 1
Group By ingPtID

or the variation

SELECT ingPtID
, COUNT (IIF(ysnACR=1,1,Null) As Quantity
FROM tVisit
Group By ingPtID

Or this variation

SELECT ingPtID
, Abs(Sum(ysnACR=1)) As Quantity
FROM tVisit
Group By ingPtID





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