Count Field Once

G

Guest

Is there any way in which I can count a field once in a query even though it
repeat quite a few times.

SELECT TimeCard.DateEntered, Sum(TimeCard.OT_HRS) AS SumOfOT_HRS,
Sum(TimeCard.PD_HRS) AS SumOfPD_HRS, Count(DriverInfo.DRIVER_ID) AS
CountOfDRIVER_ID
FROM DriverInfo INNER JOIN TimeCard ON DriverInfo.DRIVER_ID =
TimeCard.DriverID
GROUP BY TimeCard.DateEntered
HAVING (((TimeCard.DateEntered) Between [Forms]![Weekly Report
Form]![Date01] And [Forms]![Weekly Report Form]![Date02]) AND
((Sum(TimeCard.OT_HRS)) Is Not Null) AND ((Sum(TimeCard.PD_HRS)) Is Not
Null));
 
M

Michel Walsh

Hi,


You want to count the number of different occurrence of values under a
field?


SELECT COUNT(*)
FROM ( SELECT DISTINCT fieldName FROM myTable) As x


should do.


Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top